CodecType

Trait CodecType 

Source
pub trait CodecType:
    Clone
    + Send
    + Sync
    + 'static {
    // Required methods
    fn encode<T: Serialize>(value: &T) -> Result<Vec<u8>>;
    fn decode<T: DeserializeOwned>(data: &[u8]) -> Result<T>;
}
Expand description

Marker trait for codec types.

This trait is implemented by codec marker types like MsgPackCodec and [JsonCodec]. It provides the actual encode/decode functionality.

Required Methods§

Source

fn encode<T: Serialize>(value: &T) -> Result<Vec<u8>>

Encode a value to bytes.

Source

fn decode<T: DeserializeOwned>(data: &[u8]) -> Result<T>

Decode a value from bytes.

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§

Source§

impl CodecType for MsgPackCodec

Available on crate feature msgpack only.