Skip to main content

Reader

Trait Reader 

Source
pub trait Reader: Clone {
    // Required methods
    fn read<'o>(&mut self, out: &'o mut [u8]) -> Result<&'o [u8]>;
    fn remaining_len(&self) -> usize;

    // Provided method
    fn into_decoder(self) -> Result<Decoder<Self>> { ... }
}
Expand description

Byte reader for raw or incrementally decoded input.

Use Reader::into_decoder to decode SSH protocol data types. Readers only supply bytes; the decoder enforces nested length boundaries and complete consumption.

A clone starts at the same position and yields the same remaining bytes. Reading from either copy must leave the other copy’s position unchanged.

Required Methods§

Source

fn read<'o>(&mut self, out: &'o mut [u8]) -> Result<&'o [u8]>

Read as much data as is needed to exactly fill out.

Returns out reborrowed as an immutable byte slice. On success, Reader::remaining_len must decrease by exactly out.len() bytes. A read error may leave the reader partially advanced; the enclosing decoder will reject subsequent reads.

§Errors

Returns an error if the exact amount of data could not be read or decoded.

Source

fn remaining_len(&self) -> usize

Get the length of the remaining decoded data.

Provided Methods§

Source

fn into_decoder(self) -> Result<Decoder<Self>>

Consume this reader, wrapping it in a decoder for SSH protocol data types.

§Errors

Returns Error::Length if the remaining decoded input exceeds MAX_MSG_SIZE.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Reader for &[u8]

Source§

fn read<'o>(&mut self, out: &'o mut [u8]) -> Result<&'o [u8]>

Source§

fn remaining_len(&self) -> usize

Implementors§

Source§

impl Reader for Base64Reader<'_>

Available on crate feature base64 only.