pub trait Encoder {
type EncodeItem;
type EncodeError: Debug;
// Required method
fn encode(
&self,
item: Self::EncodeItem,
dst: &mut BytesMut,
) -> Result<(), Self::EncodeError>;
// Provided method
fn encode_vec(
&self,
item: Self::EncodeItem,
dst: &mut BytesVec,
) -> Result<(), Self::EncodeError> { ... }
}
Expand description
Trait of helper objects to write out messages as bytes.
Required Associated Types§
Sourcetype EncodeItem
type EncodeItem
The type of items consumed by the Encoder
Sourcetype EncodeError: Debug
type EncodeError: Debug
The type of encoding errors.
Required Methods§
Sourcefn encode(
&self,
item: Self::EncodeItem,
dst: &mut BytesMut,
) -> Result<(), Self::EncodeError>
fn encode( &self, item: Self::EncodeItem, dst: &mut BytesMut, ) -> Result<(), Self::EncodeError>
Encodes a frame into the buffer provided.
Provided Methods§
Sourcefn encode_vec(
&self,
item: Self::EncodeItem,
dst: &mut BytesVec,
) -> Result<(), Self::EncodeError>
fn encode_vec( &self, item: Self::EncodeItem, dst: &mut BytesVec, ) -> Result<(), Self::EncodeError>
Encodes a frame into the buffer provided.