Trait Codec

Source
pub trait Codec {
    type Compact;
    type Error: Into<BoxDynError>;

    // Required methods
    fn encode<I>(input: I) -> Result<Self::Compact, Self::Error>
       where I: Serialize;
    fn decode<O>(input: Self::Compact) -> Result<O, Self::Error>
       where O: for<'de> Deserialize<'de>;
}
Expand description

A codec allows backends to encode and decode data

Required Associated Types§

Source

type Compact

The mode of storage by the codec

Source

type Error: Into<BoxDynError>

Error encountered by the codec

Required Methods§

Source

fn encode<I>(input: I) -> Result<Self::Compact, Self::Error>
where I: Serialize,

The encoding method

Source

fn decode<O>(input: Self::Compact) -> Result<O, Self::Error>
where O: for<'de> Deserialize<'de>,

The decoding method

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§