Skip to main content

Codec

Trait Codec 

Source
pub trait Codec<A> {
    // Required methods
    fn encode(&self, item: A) -> Option<Vec<u8>>;
    fn decode(&self, bytes: &mut [u8]) -> Option<A>;
}
Expand description

A trait for codecs for a specic type A, usually an event type stored on a CommitLog.

Required Methods§

Source

fn encode(&self, item: A) -> Option<Vec<u8>>

Encode a value.

Source

fn decode(&self, bytes: &mut [u8]) -> Option<A>

Decode a value.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§