Trait Encoder
pub trait Encoder {
type Item;
type Error: From<Error>;
// Required method
fn encode(
&mut self,
item: Self::Item,
dst: &mut EncodeBuf<'_>,
) -> Result<(), Self::Error>;
// Provided method
fn buffer_settings(&self) -> BufferSettings { ... }
}Available on crate features
grpc and http and std only.Expand description
Encodes gRPC message types
Required Associated Types§
type Item
type Item
The type that is encoded.
Required Methods§
fn encode(
&mut self,
item: Self::Item,
dst: &mut EncodeBuf<'_>,
) -> Result<(), Self::Error>
fn encode( &mut self, item: Self::Item, dst: &mut EncodeBuf<'_>, ) -> Result<(), Self::Error>
Encodes a message into the provided buffer.
Only the message payload is to be written, gRPC framing is handled for you.
Codecs used by generated stubs have Status as their error type. The convention,
as followed by the built-in prost codec, is to map a serialisation failure with
Status::from_error_generic, which inspects the source chain and otherwise
results in crate::Code::Unknown.
Provided Methods§
fn buffer_settings(&self) -> BufferSettings
fn buffer_settings(&self) -> BufferSettings
Controls how rama-grpc creates and expands encode buffers.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".