Reader

Trait Reader 

Source
pub trait Reader {
    // Required methods
    fn capacity(&self) -> usize;
    fn skip(&mut self, len: usize) -> Result<(), WriteTooLargeError>;
    fn write_to<W: Writer>(
        &mut self,
        writer: &mut W,
        n: usize,
    ) -> Result<(), WriteTooLargeError>;

    // Provided methods
    fn write_to_buf(
        &mut self,
        buf: BufMut<'_>,
    ) -> Result<(), WriteTooLargeError> { ... }
    fn write_to_slice(
        &mut self,
        buf: &mut [u8],
    ) -> Result<(), WriteTooLargeError> { ... }
}
Expand description

An object from which bytes can be read.

Required Methods§

Source

fn capacity(&self) -> usize

Return the number of bytes that can still be read from self.

When the reader can generate arbitrary long output streams, usize::MAX is returned.

Source

fn skip(&mut self, len: usize) -> Result<(), WriteTooLargeError>

Skip over len bytes.

§Errors

Errors when len > self.capacity().

Source

fn write_to<W: Writer>( &mut self, writer: &mut W, n: usize, ) -> Result<(), WriteTooLargeError>

Write n bytes to writer.

§Errors

Errors when n exceeds reader or writer capacity.

Provided Methods§

Source

fn write_to_buf(&mut self, buf: BufMut<'_>) -> Result<(), WriteTooLargeError>

Write buf.len() bytes of data into buf.

§Errors

Errors when buf.len() exceeds reader capacity.

Source

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

Write buf.len() bytes of data into buf.

§Errors

Errors when buf.len() exceeds reader capacity.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§