pub trait Read {
// Required methods
fn capacity(&self) -> usize;
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>;
}Expand description
Implementors of the Read trait are called ‘readers’.
Readers are defined by one required method, Read::read. Each call to
Read::read will attempt to pull bytes from this source into a provided
buffer.
Required Methods§
Sourcefn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
Pull some bytes from this source into the specified buffer, returning how many bytes were read.
A successful read of n means exactly n bytes were written into
buf. It may fill only part of buf, but must not report more than
buf.len(). Ok(0) means the reader can produce no more bytes.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".