pub trait Encode {
// Required methods
fn encode<B: BufMut>(
&self,
buf: &mut B,
version: i16,
) -> Result<(), ProtocolError>;
fn encoded_len(&self, version: i16) -> usize;
}Expand description
Encode a Kafka wire-protocol value into a buffer at the given protocol version.
version is the message-level version negotiated with ApiVersionsRequest.
Implementations must produce bytes that are byte-equal to the upstream JVM
kafka-clients implementation for the same (message_type, version, value).
Required Methods§
Sourcefn encode<B: BufMut>(
&self,
buf: &mut B,
version: i16,
) -> Result<(), ProtocolError>
fn encode<B: BufMut>( &self, buf: &mut B, version: i16, ) -> Result<(), ProtocolError>
§Errors
Returns the underlying protocol error when input is truncated, contains an invalid length or tag, or cannot be encoded for the selected version.
Sourcefn encoded_len(&self, version: i16) -> usize
fn encoded_len(&self, version: i16) -> usize
Size in bytes that encode will write.
This must equal the actual count.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".