Struct io::ByteReaderWrapper

source ·
pub struct ByteReaderWrapper<R: BlockReader>(/* private fields */);
Expand description

A wrapper struct that implements a byte-wise reader atop a block-based reader.

This ideally should be realized via automatic trait implementations, in which all types that implement BlockReader also implement ByteReader, but we can’t do that because Rust currently does not support specialization.

Example

Use the From implementation around a BlockReader instance, such as:

// Assume `storage_dev` implements `BlockReader`
let bytes_read = ByteReaderWrapper::from(storage_dev).read_at(...);

Trait Implementations§

source§

impl<R> BlockIo for ByteReaderWrapper<R>where R: BlockReader,

source§

fn block_size(&self) -> usize

Returns the size in bytes of a single block (i.e., sector), the minimum granularity of I/O transfers.
source§

impl<R> BlockReader for ByteReaderWrapper<R>where R: BlockReader,

source§

fn read_blocks( &mut self, buffer: &mut [u8], block_offset: usize ) -> Result<usize, IoError>

Reads blocks of data from this reader into the given buffer. Read more
source§

impl<R> ByteReader for ByteReaderWrapper<R>where R: BlockReader,

source§

fn read_at( &mut self, buffer: &mut [u8], offset: usize ) -> Result<usize, IoError>

Reads bytes of data from this reader into the given buffer. Read more
source§

impl<R> From<R> for ByteReaderWrapper<R>where R: BlockReader,

source§

fn from(block_reader: R) -> Self

Converts to this type from the input type.
source§

impl<R> KnownLength for ByteReaderWrapper<R>where R: KnownLength + BlockReader,

source§

fn len(&self) -> usize

Returns the length (size in bytes) of this I/O stream or device.

Auto Trait Implementations§

§

impl<R> RefUnwindSafe for ByteReaderWrapper<R>where R: RefUnwindSafe,

§

impl<R> Send for ByteReaderWrapper<R>where R: Send,

§

impl<R> Sync for ByteReaderWrapper<R>where R: Sync,

§

impl<R> Unpin for ByteReaderWrapper<R>where R: Unpin,

§

impl<R> UnwindSafe for ByteReaderWrapper<R>where R: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.