pub trait Serializer: Send + Sync {
type Error: Error + Send + Sync + 'static;
// Required methods
fn content_type(&self) -> &ContentType;
fn serialize<T: Message>(&self, body: &T) -> Result<Bytes, Self::Error>;
fn deserialize<T: Message>(&self, bytes: &[u8]) -> Result<T, Self::Error>;
}Expand description
Converts a typed Message body to and from bytes. Lives in reliar-core: it touches
neither storage nor transport (ADR 0010).
Stateless and cheap; implementations SHALL NOT be placed behind a dyn Serializer on the
enqueue path (ADR 0001).
Required Associated Types§
Required Methods§
Sourcefn content_type(&self) -> &ContentType
fn content_type(&self) -> &ContentType
The content type this serializer produces. Populates both
DeliveryMetadata::content_type and a
provider’s content_type column — one value, chosen by the serializer, never by the
call site.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".