Struct io::ByteReaderWriterWrapper
source · pub struct ByteReaderWriterWrapper<RW: BlockReader + BlockWriter>(_);
Expand description
A wrapper struct that implements a byte-wise reader and writer atop a block-based reader and writer.
This ideally should be realized via automatic trait implementations,
in which all types that implement BlockReader + BlockWriter
also implement ByteReader + ByteWriter
,
but we cannot do that because Rust currently does not support specialization.
Example
Use the From
implementation around a BlockReader + BlockWriter
instance, such as:
ⓘ
// Assume `storage_dev` implements `BlockReader + BlockWriter`
let mut reader_writer = ByteReaderWriterWrapper::from(storage_dev);
let bytes_read = reader_writer.read_at(...);
let bytes_written = reader_writer.write_at(...);
Trait Implementations§
source§impl<RW> BlockIo for ByteReaderWriterWrapper<RW>where
RW: BlockReader + BlockWriter,
impl<RW> BlockIo for ByteReaderWriterWrapper<RW>where
RW: BlockReader + BlockWriter,
source§fn block_size(&self) -> usize
fn block_size(&self) -> usize
Returns the size in bytes of a single block (i.e., sector),
the minimum granularity of I/O transfers.