Trait postcard::de_flavors::Flavor

source ·
pub trait Flavor<'de>: 'de {
    type Remainder: 'de;
    type Source: 'de;

    // Required methods
    fn pop(&mut self) -> Result<u8>;
    fn try_take_n(&mut self, ct: usize) -> Result<&'de [u8]>;
    fn finalize(self) -> Result<Self::Remainder>;
}
Expand description

The deserialization Flavor trait

This is used as the primary way to decode serialized data from some kind of buffer, or modify that data in a middleware style pattern.

See the module level docs for an example of how flavors are used.

Required Associated Types§

source

type Remainder: 'de

The remaining data of this flavor after deserializing has completed.

Typically, this includes the remaining buffer that was not used for deserialization, and in cases of more complex flavors, any additional information that was decoded or otherwise calculated during the deserialization process.

source

type Source: 'de

The source of data retrieved for deserialization.

This is typically some sort of data buffer, or another Flavor, when chained behavior is desired

Required Methods§

source

fn pop(&mut self) -> Result<u8>

Obtain the next byte for deserialization

source

fn try_take_n(&mut self, ct: usize) -> Result<&'de [u8]>

Attempt to take the next ct bytes from the serialized message

source

fn finalize(self) -> Result<Self::Remainder>

Complete the deserialization process.

This is typically called separately, after the serde deserialization has completed.

Implementors§

source§

impl<'de> Flavor<'de> for Slice<'de>

§

type Remainder = &'de [u8]

§

type Source = &'de [u8]

source§

impl<'de, T> Flavor<'de> for EIOReader<'de, T>
where T: Read + 'de,

§

type Remainder = (T, &'de mut [u8])

§

type Source = &'de [u8]

source§

impl<'de, T> Flavor<'de> for IOReader<'de, T>
where T: Read + 'de,

§

type Remainder = (T, &'de mut [u8])

§

type Source = &'de [u8]