Skip to main content

Encoder

Trait Encoder 

Source
pub trait Encoder<Input: ?Sized> {
    type Output;
    type Error;

    // Required method
    fn encode(&self, input: &Input) -> Result<Self::Output, Self::Error>;
}
Expand description

Encodes a borrowed input value into an owned representation.

This trait is a convenience-layer API. Use crate::Codec for low-level single-value buffer encoding and crate::Transcoder for batch conversion over caller-provided buffers.

Required Associated Types§

Source

type Output

Encoded output type.

Source

type Error

Encoding error type.

Required Methods§

Source

fn encode(&self, input: &Input) -> Result<Self::Output, Self::Error>

Encodes input.

§Parameters
  • input: Source value to encode.
§Returns

Encoded output.

§Errors

Returns an error when the codec cannot represent the supplied input.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§