ContextualReadable

Trait ContextualReadable 

Source
pub trait ContextualReadable: DataSize {
    type Context;

    // Required method
    fn read_with(
        reader: &mut impl Buf,
        context: &Self::Context,
    ) -> ReadResult<Self>
       where Self: Sized;
}
Expand description

Allows the reading of a type from bytes given some additional Context.

Required Associated Types§

Source

type Context

The type of context with which this type can be read from bytes.

For example, this might be usize for some collection, where that usize context represents the length of the list with which to read.

Required Methods§

Source

fn read_with(reader: &mut impl Buf, context: &Self::Context) -> ReadResult<Self>
where Self: Sized,

Reads Self from a Buf of bytes, given some additional Context.

Implementations on Foreign Types§

Source§

impl<T: Readable> ContextualReadable for Vec<T>

Source§

type Context = usize

Source§

fn read_with(reader: &mut impl Buf, context: &Self::Context) -> ReadResult<Self>
where Self: Sized,

Implementors§