Struct io::ByteReaderWriterWrapper
source · pub struct ByteReaderWriterWrapper<RW: BlockReader + BlockWriter>(/* private fields */);
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.
source§impl<RW> BlockReader for ByteReaderWriterWrapper<RW>where
RW: BlockReader + BlockWriter,
impl<RW> BlockReader for ByteReaderWriterWrapper<RW>where RW: BlockReader + BlockWriter,
source§impl<RW> BlockWriter for ByteReaderWriterWrapper<RW>where
RW: BlockReader + BlockWriter,
impl<RW> BlockWriter for ByteReaderWriterWrapper<RW>where RW: BlockReader + BlockWriter,
source§impl<RW> ByteReader for ByteReaderWriterWrapper<RW>where
RW: BlockReader + BlockWriter,
impl<RW> ByteReader for ByteReaderWriterWrapper<RW>where RW: BlockReader + BlockWriter,
source§impl<RW> ByteWriter for ByteReaderWriterWrapper<RW>where
RW: BlockReader + BlockWriter,
impl<RW> ByteWriter for ByteReaderWriterWrapper<RW>where RW: BlockReader + BlockWriter,
source§impl<RW> From<RW> for ByteReaderWriterWrapper<RW>where
RW: BlockReader + BlockWriter,
impl<RW> From<RW> for ByteReaderWriterWrapper<RW>where RW: BlockReader + BlockWriter,
source§impl<RW> KnownLength for ByteReaderWriterWrapper<RW>where
RW: KnownLength + BlockReader + BlockWriter,
impl<RW> KnownLength for ByteReaderWriterWrapper<RW>where RW: KnownLength + BlockReader + BlockWriter,
Auto Trait Implementations§
impl<RW> RefUnwindSafe for ByteReaderWriterWrapper<RW>where RW: RefUnwindSafe,
impl<RW> Send for ByteReaderWriterWrapper<RW>where RW: Send,
impl<RW> Sync for ByteReaderWriterWrapper<RW>where RW: Sync,
impl<RW> Unpin for ByteReaderWriterWrapper<RW>where RW: Unpin,
impl<RW> UnwindSafe for ByteReaderWriterWrapper<RW>where RW: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more