Codec

Trait Codec 

Source
pub trait Codec<Input, Output, Error> {
    // Required methods
    fn as_encoder(&mut self) -> &mut dyn Encoder<Input, Error = Error>;
    fn as_decoder(&mut self) -> &mut dyn Decoder<Item = Output, Error = Error>;
}

Required Methods§

Source

fn as_encoder(&mut self) -> &mut dyn Encoder<Input, Error = Error>

Source

fn as_decoder(&mut self) -> &mut dyn Decoder<Item = Output, Error = Error>

Trait Implementations§

Source§

impl<I, O, E: From<Error>> Decoder for Box<dyn Codec<I, O, E> + Send + Sync + Unpin>

Source§

type Error = E

The type of unrecoverable frame decoding errors. Read more
Source§

type Item = O

The type of decoded frames.
Source§

fn decode( &mut self, src: &mut BytesMut, ) -> Result<Option<Self::Item>, Self::Error>

Attempts to decode a frame from the provided buffer of bytes. Read more
Source§

fn decode_eof( &mut self, buf: &mut BytesMut, ) -> Result<Option<Self::Item>, Self::Error>

A default method available to be called when there are no more bytes available to be read from the underlying I/O. Read more
Source§

fn framed<T>(self, io: T) -> Framed<T, Self>
where T: AsyncRead + AsyncWrite, Self: Sized,

Provides a Stream and Sink interface for reading and writing to this Io object, using Decode and Encode to read and write the raw data. Read more
Source§

impl<I, O, E: From<Error>> Encoder<I> for Box<dyn Codec<I, O, E> + Send + Sync + Unpin>

Source§

type Error = E

The type of encoding errors. Read more
Source§

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

Encodes a frame into the buffer provided. Read more

Implementors§

Source§

impl<T, I, O, E> Codec<I, O, E> for T
where T: Encoder<I, Error = E> + Decoder<Item = O, Error = E>,