Trait tonic::codec::Codec

source ·
pub trait Codec {
    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.

Implementors§

source§

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

§

type Encode = T

§

type Decode = U

§

type Encoder = ProstEncoder<T>

§

type Decoder = ProstDecoder<U>