Skip to main content

Protocol

Trait Protocol 

Source
pub trait Protocol {
    type Message;

    const SCHEMA_ID: [u8; 32];

    // Required methods
    fn encode_payload(
        message: &Self::Message,
        destination: &mut [u8],
    ) -> Result<usize, EncodeError>;
    fn decode_payload(
        source: &[u8],
        context: &mut DecodeContext<'_>,
    ) -> Result<Self::Message, DecodeError>;
}
Expand description

Explicit protocol payload codec.

Implementations must manually encode fixed-width values and must apply the decode context before allocation or record construction. The common envelope is encoded and validated by encode_message and decode_message.

Required Associated Constants§

Source

const SCHEMA_ID: [u8; 32]

Exact 256-bit schema identity for this protocol revision.

Required Associated Types§

Source

type Message

Safe, owned protocol message representation.

Required Methods§

Source

fn encode_payload( message: &Self::Message, destination: &mut [u8], ) -> Result<usize, EncodeError>

Encodes only the protocol-specific payload.

Source

fn decode_payload( source: &[u8], context: &mut DecodeContext<'_>, ) -> Result<Self::Message, DecodeError>

Decodes hostile payload bytes into an owned safe value.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§