Skip to main content

Encoding

Trait Encoding 

Source
pub trait Encoding<T> {
    const CONTENT_TYPE: &'static str = "application/octet-stream";

    // Required methods
    fn encode(value: &T) -> Result<Vec<u8>, Error>;
    fn decode(raw: &[u8]) -> Result<T, Error>;
}
Expand description

Wire encoding for a topic’s messages.

Provided Associated Constants§

Source

const CONTENT_TYPE: &'static str = "application/octet-stream"

The media type of the encoded bytes, sent in CONTENT_TYPE_ATTRIBUTE.

Required Methods§

Source

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

Source

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

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl Encoding<Vec<u8>> for Raw

Source§

impl<T: Serialize + DeserializeOwned> Encoding<T> for Json

Source§

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