Trait Codec
pub trait Codec:
Send
+ Sync
+ 'static {
type Encode: Send + Sync + 'static;
type Decode: Send + Sync + 'static;
type Encoder: Encoder<Item = Self::Encode, Error = Status> + Send + Sync + 'static;
type Decoder: Decoder<Item = Self::Decode, Error = Status> + Send + Sync + 'static;
// Required methods
fn encoder(&mut self) -> Self::Encoder;
fn decoder(&mut self) -> Self::Decoder;
}Available on crate features
grpc and http and std only.Expand description
Trait that knows how to encode and decode gRPC messages.
§Content type
rama-grpc always sends and accepts application/grpc, on both the client and the server,
regardless of the codec in use. There is no per-codec subtype (such as
application/grpc+proto or application/grpc+json) and no content type negotiation:
the codec is chosen by the generated stub, not by the peer.
A consequence is that a client and a server which are wired up with different codecs for the same path do not fail the handshake, they mis-decode each other’s messages instead. Make sure both ends of a route are generated with the same codec.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".