Skip to main content

EnvelopeCodec

Trait EnvelopeCodec 

Source
pub trait EnvelopeCodec: Send + Sync {
    // Required methods
    fn encode(&self, envelope: &Envelope) -> Result<Vec<u8>, EnvelopeError>;
    fn decode(&self, data: &[u8]) -> Result<Envelope, EnvelopeError>;
}
Expand description

A codec that serializes and deserializes Envelopes.

Implementations must be Send + Sync so they can be shared across async tasks behind an Arc.

§Default implementation

JsonCodec — produces compact JSON. Suitable for debugging and low-to-medium throughput applications.

Required Methods§

Source

fn encode(&self, envelope: &Envelope) -> Result<Vec<u8>, EnvelopeError>

Encode an envelope into a byte buffer.

Source

fn decode(&self, data: &[u8]) -> Result<Envelope, EnvelopeError>

Decode an envelope from a byte buffer.

Implementors§