Skip to main content

EnvelopeMapper

Trait EnvelopeMapper 

Source
pub trait EnvelopeMapper<M> {
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn encode(&self, envelope: &SerializedEnvelope) -> Result<M, Self::Error>;
    fn decode(&self, message: M) -> Result<SerializedEnvelope, Self::Error>;
}
Expand description

Converts a SerializedEnvelope to and from one transport’s native message type M.

No implementation ships from reliar-core — a mapper’s transport headers are a projection of Metadata, not a second source of truth (ADR 0004). The reserved reliar-* header names a mapper writes are a public contract (§14).

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

The mapper’s own error type.

Required Methods§

Source

fn encode(&self, envelope: &SerializedEnvelope) -> Result<M, Self::Error>

Encodes a canonical envelope into the transport’s native message type.

§Errors

Returns Self::Error if the transport’s native message type cannot represent the envelope (e.g. a field it cannot carry).

Source

fn decode(&self, message: M) -> Result<SerializedEnvelope, Self::Error>

Decodes a transport message back into a canonical envelope.

§Errors

Returns Self::Error if the transport message cannot be decoded into a canonical envelope (a missing required framework header, or a malformed one).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§