pub trait Read {
// Required method
fn read(&mut self, buf: &mut [u8]) -> Result<usize, AxError>;
// Provided methods
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), AxError> { ... }
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), AxError> { ... }
fn read_buf_exact(
&mut self,
cursor: BorrowedCursor<'_>,
) -> Result<(), AxError> { ... }
fn by_ref(&mut self) -> &mut Self
where Self: Sized { ... }
fn chain<R>(self, next: R) -> Chain<Self, R>
where R: Read,
Self: Sized { ... }
fn take(self, limit: u64) -> Take<Self>
where Self: Sized { ... }
}Expand description
The Read trait allows for reading bytes from a source.
See [std::io::Read] for more details.
Required Methods§
Provided Methods§
Sourcefn read_exact(&mut self, buf: &mut [u8]) -> Result<(), AxError>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), AxError>
Read the exact number of bytes required to fill buf.
Sourcefn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), AxError>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), AxError>
Pull some bytes from this source into the specified buffer.
This method makes it possible to return both data and an error but it is advised against.
Sourcefn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), AxError>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), AxError>
Reads the exact number of bytes required to fill cursor.
If this function returns an error, all bytes read will be appended to cursor.
Sourcefn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Creates a “by reference” adapter for this instance of Read.
The returned adapter also implements Read and will simply borrow this
current reader.
Sourcefn chain<R>(self, next: R) -> Chain<Self, R>
fn chain<R>(self, next: R) -> Chain<Self, R>
Creates an adapter which will chain this stream with another.
The returned Read instance will first read all bytes from this object
until EOF is encountered. Afterwards the output is equivalent to the
output of next.