Trait Reads

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

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

A thing that reads from a stream of bytes.

Required Methods§

Source

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

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

No more than buf.len() bytes will be read.

If an error occurs, the state of buf and the number of bytes read is undefined.

Provided Methods§

Source

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

Reads exactly buf.len() bytes into buf.

If an error occurs, the state of buf and the number of bytes read is undefined.

Implementors§

Source§

impl<T> Reads for T
where T: Read,