Skip to main content

Read

Trait Read 

Source
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()]. Each call to [read()] will attempt to pull bytes from this source into a provided buffer.

Required Methods§

Source

fn capacity(&self) -> usize

Returns the number of elements the Reader can hold.

Source

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.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Read for &[u8]

Source§

fn capacity(&self) -> usize

Source§

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

Implementors§