Skip to main content

PayloadEncode

Trait PayloadEncode 

Source
pub trait PayloadEncode: PayloadHooks + ProtocolSchema {
    // Required method
    fn encode(&self, ctx: &mut Self::Context<'_>) -> Result<Vec<u8>>;
}
Expand description

Trait for serializing a payload into a byte buffer.

Requires PayloadHooks, so before_encode() will always be invoked before encoding.

Required Methods§

Source

fn encode(&self, ctx: &mut Self::Context<'_>) -> Result<Vec<u8>>

Serializes the payload body into a standalone byte buffer.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl PayloadEncode for String

Source§

fn encode(&self, _: &mut Self::Context<'_>) -> Result<Vec<u8>>

Source§

impl PayloadEncode for Vec<u8>

Source§

fn encode(&self, _: &mut Self::Context<'_>) -> Result<Vec<u8>>

Implementors§