Struct io::ReaderWriter
source · pub struct ReaderWriter<IO> { /* private fields */ }
Expand description
A readable and writable “stateful” I/O stream that keeps track of its current offset within its internal stateless I/O stream.
Trait implementations
- This implements the [
core2::io::Read
] and [core2::io::Write
] traits for read and write access. - This implements the [
core2::io::Seek
] trait if the underlying I/O stream implementsKnownLength
. - This also forwards all other I/O-related traits implemented by the underlying I/O stream.
- This derefs into the inner
IO
type, via bothDeref
andDerefMut
.
Implementations§
source§impl<IO> ReaderWriter<IO>where
IO: ByteReader + ByteWriter,
impl<IO> ReaderWriter<IO>where IO: ByteReader + ByteWriter,
sourcepub fn new(io: IO) -> ReaderWriter<IO>
pub fn new(io: IO) -> ReaderWriter<IO>
Creates a new ReaderWriter
with an initial offset of 0.
Trait Implementations§
source§impl<IO> BlockIo for ReaderWriter<IO>where
IO: BlockIo,
impl<IO> BlockIo for ReaderWriter<IO>where IO: BlockIo,
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<IO> BlockReader for ReaderWriter<IO>where
IO: BlockReader,
impl<IO> BlockReader for ReaderWriter<IO>where IO: BlockReader,
source§impl<IO> BlockWriter for ReaderWriter<IO>where
IO: BlockWriter,
impl<IO> BlockWriter for ReaderWriter<IO>where IO: BlockWriter,
source§impl<IO> ByteReader for ReaderWriter<IO>where
IO: ByteReader,
impl<IO> ByteReader for ReaderWriter<IO>where IO: ByteReader,
source§impl<IO> ByteWriter for ReaderWriter<IO>where
IO: ByteWriter,
impl<IO> ByteWriter for ReaderWriter<IO>where IO: ByteWriter,
source§impl<IO> Deref for ReaderWriter<IO>
impl<IO> Deref for ReaderWriter<IO>
source§impl<IO> DerefMut for ReaderWriter<IO>
impl<IO> DerefMut for ReaderWriter<IO>
source§impl<IO> KnownLength for ReaderWriter<IO>where
IO: KnownLength,
impl<IO> KnownLength for ReaderWriter<IO>where IO: KnownLength,
source§impl<IO> Read for ReaderWriter<IO>where
IO: ByteReader,
impl<IO> Read for ReaderWriter<IO>where IO: ByteReader,
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning
how many bytes were read. Read more
§fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
Read all bytes until EOF in this source, placing them into
buf
. Read more§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
Read all bytes until EOF in this source, appending them to
buf
. Read more§unsafe fn initializer(&self) -> Initializer
unsafe fn initializer(&self) -> Initializer
Determines if this
Read
er can work with buffers of uninitialized
memory. Read more§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
Read the exact number of bytes required to fill
buf
. Read more§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere Self: Sized,
Creates a “by reference” adaptor for this instance of
Read
. Read moresource§impl<IO> Seek for ReaderWriter<IO>where
IO: KnownLength,
impl<IO> Seek for ReaderWriter<IO>where IO: KnownLength,
source§fn seek(&mut self, position: SeekFrom) -> Result<u64>
fn seek(&mut self, position: SeekFrom) -> Result<u64>
Seek to an offset, in bytes, in a stream. Read more
§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
Returns the length of this stream (in bytes). Read more
§fn stream_position(&mut self) -> Result<u64, Error>
fn stream_position(&mut self) -> Result<u64, Error>
Returns the current seek position from the start of the stream. Read more
source§impl<IO> Write for ReaderWriter<IO>where
IO: ByteWriter,
impl<IO> Write for ReaderWriter<IO>where IO: ByteWriter,
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this writer, returning how many bytes were written. Read more
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
Auto Trait Implementations§
impl<IO> RefUnwindSafe for ReaderWriter<IO>where IO: RefUnwindSafe,
impl<IO> Send for ReaderWriter<IO>where IO: Send,
impl<IO> Sync for ReaderWriter<IO>where IO: Sync,
impl<IO> Unpin for ReaderWriter<IO>where IO: Unpin,
impl<IO> UnwindSafe for ReaderWriter<IO>where IO: 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