Skip to main content

CratestackCodec

Trait CratestackCodec 

pub trait CratestackCodec:
    Clone
    + Send
    + Sync
    + 'static {
    const CONTENT_TYPE: &'static str;

    // Required methods
    fn encode<T>(&self, value: &T) -> Result<Vec<u8>, CratestackError>
       where T: Serialize + ?Sized;
    fn decode<T>(&self, bytes: &[u8]) -> Result<T, CratestackError>
       where T: for<'de> Deserialize<'de>;
}

Required Associated Constants§

const CONTENT_TYPE: &'static str

Required Methods§

fn encode<T>(&self, value: &T) -> Result<Vec<u8>, CratestackError>
where T: Serialize + ?Sized,

fn decode<T>(&self, bytes: &[u8]) -> Result<T, CratestackError>
where T: for<'de> Deserialize<'de>,

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

§

impl CratestackCodec for CborCodec

§

const CONTENT_TYPE: &'static str = "application/cbor"

§

fn encode<T>(&self, value: &T) -> Result<Vec<u8>, CratestackError>
where T: Serialize + ?Sized,

§

fn decode<T>(&self, bytes: &[u8]) -> Result<T, CratestackError>
where T: for<'de> Deserialize<'de>,

§

impl CratestackCodec for JsonCodec

§

const CONTENT_TYPE: &'static str = "application/json"

§

fn encode<T>(&self, value: &T) -> Result<Vec<u8>, CratestackError>
where T: Serialize + ?Sized,

§

fn decode<T>(&self, bytes: &[u8]) -> Result<T, CratestackError>
where T: for<'de> Deserialize<'de>,

Implementors§