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.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Encoder for BytesCodec

§

type Item<'a> = Bytes

§

type Error = Error

source§

impl Encoder for LengthCodec

§

type Item<'a> = Bytes

§

type Error = Error

source§

impl Encoder for LinesCodec

§

type Item<'a> = String

§

type Error = Error

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

§

type Item<'a> = Enc

§

type Error = CborCodecError

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

§

type Item<'a> = Enc

§

type Error = JsonCodecError