Skip to main content

PayloadEncodeReferred

Trait PayloadEncodeReferred 

Source
pub trait PayloadEncodeReferred: ProtocolSchema {
    // Required method
    fn encode(&self, ctx: &mut Self::Context<'_>) -> Result<Option<&[u8]>>;
}
Expand description

Provides an optional reference to an already-encoded payload.

This is a performance optimization: if the payload was already serialized, this trait can return a reference to the existing bytes and skip re-encoding.

Useful in zero-copy or deferred encoding scenarios.

Required Methods§

Source

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

Returns a borrowed encoded payload body when one is already available.

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 PayloadEncodeReferred for String

Source§

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

Source§

impl PayloadEncodeReferred for Vec<u8>

Source§

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

Implementors§