Skip to main content

Codec

Trait Codec 

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

Deterministic serialization boundary used by durable stores.

Required Methods§

Source

fn encode(&self, value: &T) -> Result<Vec<u8>>

Encodes one value.

§Errors

Returns a codec-specific serialization error.

Source

fn decode(&self, bytes: &[u8]) -> Result<T>

Decodes one complete value.

§Errors

Returns a codec-specific deserialization error.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Codec<ProjectionSnapshot<MemoryProjection>> for CompactSnapshotCodec

Source§

impl<T, C, K, N> Codec<T> for XChaCha20Codec<C, K, N>
where C: Codec<T>, K: EncryptionKeys, N: NonceSource,

Source§

impl<T, C> Codec<T> for Lz4Codec<C>
where C: Codec<T>,

Source§

impl<T> Codec<T> for JsonCodec

Available on crate feature json only.