Trait Read

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

    // Provided methods
    fn chain<R>(self, next: R) -> Chain<Self, R> 
       where Self: Sized,
             R: Read { ... }
    fn buffer(self) -> BufReader<Self>
       where Self: Sized { ... }
    fn repeat(self) -> Repeat<Self> 
       where Self: Sized { ... }
}
Expand description

Alternative to std::io::Read

This trait is automatically implemented for all types that implement std::io::Read.

§Diffrerences to std::io::Read

Methods that are just wrappers around the equivalent methods of std::io::Read:

  • read
  • chain

New methods that have no counterpart in std::io::Read:

  • buffer
  • repeat

Functions that were removed or moved to a different place, because they cannot be implemented with providing all desired guarantees:

Required Methods§

Source

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

Pull some bytes from this source into the specified buffer, returning how many bytes were read.

This methode is equivalent to std::io::Read::read.

Provided Methods§

Source

fn chain<R>(self, next: R) -> Chain<Self, R>
where Self: Sized, R: Read,

Creates an adaptor which will chain this stream with another.

This method is equivalent to std::io::Read::chain.

Source

fn buffer(self) -> BufReader<Self>
where Self: Sized,

Creates a buffered reader with default capacity and default strategies

Please see the documentation of BufReader for more details

Source

fn repeat(self) -> Repeat<Self>
where Self: Sized,

Transforms this reader into a reader that automatically restarts from the beginning after EOF is reached

Implementations on Foreign Types§

Source§

impl Read for File

Source§

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

Source§

impl Read for Stdin

Source§

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

Source§

impl Read for Empty

Source§

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

Source§

impl Read for Repeat

Source§

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

Source§

impl Read for TcpStream

Source§

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

Source§

impl Read for UnixStream

Source§

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

Source§

impl Read for ChildStderr

Source§

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

Source§

impl Read for ChildStdout

Source§

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

Source§

impl<'a> Read for &'a File

Source§

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

Source§

impl<'a> Read for &'a TcpStream

Source§

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

Source§

impl<'a> Read for &'a UnixStream

Source§

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

Source§

impl<'a> Read for &'a [u8]

Source§

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

Source§

impl<'a> Read for StdinLock<'a>

Source§

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

Source§

impl<'a, R: Read + ?Sized> Read for &'a mut R

Source§

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

Source§

impl<R, Rs, Ms> Read for BufReader<R, Rs, Ms>
where R: Read, Rs: ReadStrategy, Ms: MoveStrategy,

Source§

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

Source§

impl<R: Read> Read for BufReader<R>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<T: Read> Read for Take<T>

Source§

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

Source§

impl<T: Read, U: Read> Read for Chain<T, U>

Source§

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

Implementors§

Source§

impl<I: Read + Seek> Read for netio::Repeat<I>

Source§

impl<I: Read> Read for Retry<I>

Source§

impl<R: Read> Read for Compat<R>

Source§

impl<R: Read> Read for Throttled<R>

Source§

impl<R: Read> Read for Collect<R>

Source§

impl<T: Read> Read for Limited<T>

Source§

impl<T: Read> Read for netio::Take<T>

Source§

impl<T: Read, U: Read> Read for netio::Chain<T, U>