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§
Sourcefn serialise_json_value(&self, value: &Value) -> Result<ValueBytes>
fn serialise_json_value(&self, value: &Value) -> Result<ValueBytes>
Serialises a JSON value into bytes for storage.
Sourcefn deserialise_json_value(&self, bytes: &ValueBytes) -> Result<Value>
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".