Skip to main content

Message

Trait Message 

Source
pub trait Message:
    Sized
    + Send
    + Sync {
    const CODEC: &'static str;

    // Required methods
    fn encode(&self) -> Vec<u8> ⓘ;
    fn encoded_size(&self) -> usize;
    fn decode(bytes: &[u8]) -> Result<Self, MessageError>;
    fn decoding_memory(bytes: &[u8]) -> Result<usize, MessageError>;

    // Provided method
    fn encode_into(&self, bytes: &mut Vec<u8>) { ... }
}

Required Associated Constants§

Source

const CODEC: &'static str

Required Methods§

Source

fn encode(&self) -> Vec<u8> ⓘ

Source

fn encoded_size(&self) -> usize

Source

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

Source

fn decoding_memory(bytes: &[u8]) -> Result<usize, MessageError>

Provided Methods§

Source

fn encode_into(&self, bytes: &mut Vec<u8>)

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<L> Message for Delivery<L>
where L: Listener,

Source§

const CODEC: &'static str = "harmos.postcard.v1"

Source§

impl<T> Message for T
where T: Value,

Source§

const CODEC: &'static str = "harmos.postcard.v1"