Trait Codec

Source
pub trait Codec: Default {
    type Encode: Send + 'static;
    type Decode: Send + 'static;
    type Encoder: Encoder<Item = Self::Encode, Error = Status> + Send + 'static;
    type Decoder: Decoder<Item = Self::Decode, Error = Status> + Send + 'static;

    // Required methods
    fn encoder(&mut self) -> Self::Encoder;
    fn decoder(&mut self) -> Self::Decoder;
}
Expand description

Trait that knows how to encode and decode gRPC messages.

Required Associated Types§

Source

type Encode: Send + 'static

The encodable message.

Source

type Decode: Send + 'static

The decodable message.

Source

type Encoder: Encoder<Item = Self::Encode, Error = Status> + Send + 'static

The encoder that can encode a message.

Source

type Decoder: Decoder<Item = Self::Decode, Error = Status> + Send + 'static

The encoder that can decode a message.

Required Methods§

Source

fn encoder(&mut self) -> Self::Encoder

Fetch the encoder.

Source

fn decoder(&mut self) -> Self::Decoder

Fetch the decoder.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T, U> Codec for ProstCodec<T, U>
where T: Message + Send + 'static, U: Message + Default + Send + 'static,

Source§

type Encode = T

Source§

type Decode = U

Source§

type Encoder = ProstEncoder<T>

Source§

type Decoder = ProstDecoder<U>