Codec

Trait Codec 

Source
pub trait Codec {
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn serialize<T>(&self, value: &T) -> Result<Vec<u8>, Self::Error>
       where T: Serialize;
    fn deserialize<T>(&self, data: &[u8]) -> Result<T, Self::Error>
       where T: DeserializeOwned;
}
Expand description

Serialisation strategy used by event stores.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Required Methods§

Source

fn serialize<T>(&self, value: &T) -> Result<Vec<u8>, Self::Error>
where T: Serialize,

Serialize a value for persistence.

§Errors

Returns an error from the codec if the value cannot be serialized.

Source

fn deserialize<T>(&self, data: &[u8]) -> Result<T, Self::Error>

Deserialize a value from stored bytes.

§Errors

Returns an error from the codec if the bytes cannot be decoded.

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§