Skip to main content

Codec

Trait Codec 

Source
pub trait Codec: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn serialise_json_value(&self, value: &Value) -> Result<ValueBytes>;
    fn deserialise_json_value(&self, bytes: &ValueBytes) -> Result<Value>;
}
Expand description

Object-safe codec contract used by stores.

The byte-level methods keep the trait usable behind dyn Codec. The CodecExt extension trait provides ergonomic typed serialise and deserialise helpers for all codec implementations.

Required Methods§

Source

fn name(&self) -> &'static str

Stable codec name stored in value metadata.

Source

fn serialise_json_value(&self, value: &Value) -> Result<ValueBytes>

Serialises a JSON value into bytes for storage.

Source

fn deserialise_json_value(&self, bytes: &ValueBytes) -> Result<Value>

Deserialises bytes into a JSON value.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§