Skip to main content

PayloadCodec

Trait PayloadCodec 

Source
pub trait PayloadCodec {
    type Error: Error + Send + Sync + 'static;

    const NAME: &'static str;
    const VERSION: u16;

    // Required methods
    fn encode<T: Serialize + ?Sized>(value: &T) -> Result<Vec<u8>, Self::Error>;
    fn decode<T: DeserializeOwned>(bytes: &[u8]) -> Result<T, Self::Error>;
}
Expand description

Codec used to serialize and deserialize event payload bytes.

Required Associated Constants§

Source

const NAME: &'static str

Source

const VERSION: u16

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Required Methods§

Source

fn encode<T: Serialize + ?Sized>(value: &T) -> Result<Vec<u8>, Self::Error>

Source

fn decode<T: DeserializeOwned>(bytes: &[u8]) -> Result<T, Self::Error>

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl PayloadCodec for BitcodePayloadCodec

Source§

const NAME: &'static str = BITCODE_PAYLOAD_CODEC

Source§

const VERSION: u16 = BITCODE_PAYLOAD_CODEC_VERSION

Source§

type Error = Error