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
- A cheaply cloneable and sliceable chunk of contiguous memory.
- A simple codec that ships bytes around
- A unique reference to a contiguous slice of memory.
- A unified
StreamandSinkinterface to an underlying I/O object, using theEncoderandDecodertraits to encode and decode frames. - The parts obtained from
Framed::into_parts. - A
Streamof messages decoded from anAsyncRead. - The parts obtained from (FramedRead::into_parts).
- A
Sinkof frames encoded to anAsyncWrite. - The parts obtained from
FramedWrite::into_parts. - A simple
Codecimplementation sending your data by prefixing it by its length. - A simple
Codecimplementation that splits up data into lines.
Traits
- Decoding of frames via buffers, for use with
FramedRead. - Encoding of messages as bytes, for use with
FramedWrite.