Skip to main content

Read

Trait Read 

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

    // Provided method
    fn read_exact(&mut self, buf: &mut [u8]) -> Result<()> { ... }
}
Expand description

no_std-compatible read/write traits used by streaming APIs. no_std-compatible read trait used by streaming interfaces.

This trait is intentionally close to std::io::Read so the same code can be shared across std and no_std builds.

Required Methods§

Source

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

Reads bytes into buf, returning the number of bytes read.

Provided Methods§

Source

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

Reads exactly buf.len() bytes into buf.

Returns:

  • Ok(()) if the buffer was fully filled.
  • Err(Error::Eof) if input ended early.

Implementors§

Source§

impl<R: Read + ?Sized> Read for R

Available on crate feature std only.
Source§

impl<R: Read> Read for LzfReader<R>