Skip to main content

DntCodec

Trait DntCodec 

Source
pub trait DntCodec: Send + Sync {
    // Required methods
    fn codec_id(&self) -> CodecId;
    fn encode(&self, value: &[u8]) -> Result<Vec<u8>, CodecError>;
    fn decode(&self, payload: &[u8]) -> Result<Vec<u8>, CodecError>;

    // Provided methods
    fn matches_codec_id(&self, codec_id: &CodecId) -> bool { ... }
    fn decode_owned(&self, payload: Vec<u8>) -> Result<Vec<u8>, CodecError> { ... }
}
Expand description

Payload codec used before encryption and after authentication.

Required Methods§

Source

fn codec_id(&self) -> CodecId

Returns the stable codec identifier.

Source

fn encode(&self, value: &[u8]) -> Result<Vec<u8>, CodecError>

Encodes caller-owned bytes before sealing.

Source

fn decode(&self, payload: &[u8]) -> Result<Vec<u8>, CodecError>

Decodes authenticated plaintext bytes after opening.

Provided Methods§

Source

fn matches_codec_id(&self, codec_id: &CodecId) -> bool

Returns true when this codec can decode the authenticated identifier.

Source

fn decode_owned(&self, payload: Vec<u8>) -> Result<Vec<u8>, CodecError>

Decodes an owned authenticated payload after opening.

Codecs that are identity transforms can return payload directly to avoid an allocation in the read path. Transforming codecs may keep the default implementation.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§