Crate asynchronous_codec

Source
Expand description

Utilities for encoding and decoding frames using async/await.

Contains adapters to go from streams of bytes, AsyncRead and AsyncWrite, to framed streams implementing Sink and Stream. Framed streams are also known as transports.

use futures::TryStreamExt;
use futures::io::Cursor;
use asynchronous_codec::{LinesCodec, Framed};

let io = Cursor::new(Vec::new());
let mut framed = Framed::new(io, LinesCodec);

while let Some(line) = framed.try_next().await? {
    dbg!(line);
}

Structs§

Bytes
A cheaply cloneable and sliceable chunk of contiguous memory.
BytesCodec
A simple codec that ships bytes around
BytesMut
A unique reference to a contiguous slice of memory.
Framed
A unified Stream and Sink interface to an underlying I/O object, using the Encoder and Decoder traits to encode and decode frames.
FramedParts
The parts obtained from Framed::into_parts.
FramedRead
A Stream of messages decoded from an AsyncRead.
FramedReadParts
The parts obtained from (FramedRead::into_parts).
FramedWrite
A Sink of frames encoded to an AsyncWrite.
FramedWriteParts
The parts obtained from FramedWrite::into_parts.
LengthCodec
A simple Codec implementation sending your data by prefixing it by its length.
LinesCodec
A simple Codec implementation that splits up data into lines.

Traits§

Decoder
Decoding of frames via buffers, for use with FramedRead.
Encoder
Encoding of messages as bytes, for use with FramedWrite.