Skip to main content

DistributedSerializer

Trait DistributedSerializer 

Source
pub trait DistributedSerializer<V>: Send + Sync {
    // Required methods
    fn serialize(&self, entry: &DistributedEntry<V>) -> Result<Vec<u8>>;
    fn deserialize(&self, bytes: &[u8]) -> Result<DistributedEntry<V>>;
}
Expand description

Encodes and decodes DistributedEntry values for the wire.

This is object-safe (no generic methods), so a cache holds it as Arc<dyn DistributedSerializer<V>> and the serialization format is fully pluggable.

Required Methods§

Source

fn serialize(&self, entry: &DistributedEntry<V>) -> Result<Vec<u8>>

Serializes an envelope to bytes.

§Errors

Returns Error::Serialization if encoding fails.

Source

fn deserialize(&self, bytes: &[u8]) -> Result<DistributedEntry<V>>

Deserializes an envelope from bytes.

§Errors

Returns Error::Deserialization if decoding fails.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§