Skip to main content

Codec

Trait Codec 

Source
pub trait Codec {
    // Required methods
    fn id(&self) -> &str;
    fn serialize(&self, value: &Value) -> Result<Vec<u8>>;
    fn deserialize(&self, bytes: &[u8]) -> Result<Value>;
}

Required Methods§

Source

fn id(&self) -> &str

Return the stable codec identity shared with other adapters.

Source

fn serialize(&self, value: &Value) -> Result<Vec<u8>>

Encode portable values using this codec’s wire contract.

Source

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

Decode portable values without narrowing large integers.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§