Trait Decoder
pub trait Decoder {
type Item;
type Error: From<Error>;
// Required method
fn decode(
&mut self,
src: &mut DecodeBuf<'_>,
) -> Result<Option<Self::Item>, Self::Error>;
// Provided method
fn buffer_settings(&self) -> BufferSettings { ... }
}grpc and http and std only.Expand description
Decodes gRPC message types
Required Associated Types§
type Item
type Item
The type that is decoded.
Required Methods§
fn decode(
&mut self,
src: &mut DecodeBuf<'_>,
) -> Result<Option<Self::Item>, Self::Error>
fn decode( &mut self, src: &mut DecodeBuf<'_>, ) -> Result<Option<Self::Item>, Self::Error>
Decode a message from the buffer.
The buffer will contain exactly the bytes of a full message. There is no need to get the length from the bytes, gRPC framing is handled for you.
Because of that, an implementation must return Ok(Some(item)) for every
message it is given: Ok(None) means “not enough data yet” and makes the
framework wait for bytes which will never come, stalling the stream.
Report a malformed message as an error instead.
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 parse failure to
Status::internal, as per the gRPC status codes doc.
Provided Methods§
fn buffer_settings(&self) -> BufferSettings
fn buffer_settings(&self) -> BufferSettings
Controls how rama-grpc creates and expands decode buffers.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".