asynchronous_codec

Trait Encoder

Source
pub trait Encoder {
    type Item<'a>;
    type Error: From<Error>;

    // Required method
    fn encode(
        &mut self,
        item: Self::Item<'_>,
        dst: &mut BytesMut,
    ) -> Result<(), Self::Error>;
}
Expand description

Encoding of messages as bytes, for use with FramedWrite.

Required Associated Types§

Source

type Item<'a>

The type of items consumed by encode

Source

type Error: From<Error>

The type of encoding errors.

Required Methods§

Source

fn encode( &mut self, item: Self::Item<'_>, dst: &mut BytesMut, ) -> Result<(), Self::Error>

Encodes an item into the BytesMut provided by dst.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Encoder for BytesCodec

Source§

impl Encoder for LengthCodec

Source§

impl Encoder for LinesCodec

Source§

impl<Enc, Dec> Encoder for CborCodec<Enc, Dec>
where for<'de> Dec: Deserialize<'de> + 'static, for<'de> Enc: Serialize + 'static,

Encoder impl encodes object streams to bytes

Source§

impl<Enc, Dec> Encoder for JsonCodec<Enc, Dec>
where for<'de> Dec: Deserialize<'de> + 'static, for<'de> Enc: Serialize + 'static,

Encoder impl encodes object streams to bytes