Skip to main content

Read

Trait Read 

Source
pub trait Read<T> {
    // Required method
    fn read(&mut self, buf: &mut dyn AsMut<[T]>) -> Result<usize>;

    // Provided method
    fn read_exact(&mut self, buf: &mut dyn AsMut<[T]>) -> Result<()> { ... }
}

Required Methods§

Source

fn read(&mut self, buf: &mut dyn AsMut<[T]>) -> Result<usize>

Reads from this source once and places the result in [buf]. Returns the number of bytes read. This method does not guarantee to read [buf] fully. For that, see Read::read_exact.

Provided Methods§

Source

fn read_exact(&mut self, buf: &mut dyn AsMut<[T]>) -> Result<()>

Reads the full buffer from this source. Might block if the implementation of Read::read blocks. If this returns Result::Ok, then the full buffer has been read. If it returns Result::Err, then either an error occurred during Read::read or the source is at EOF, in which case Error::PrematureEndOfInput is returned.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> Read<u8> for Cursor<T>
where T: AsRef<[u8]>,