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.
- Bytes
Codec - A simple codec that ships bytes around
- Bytes
Mut - A unique reference to a contiguous slice of memory.
- Cbor
Codec - A codec for JSON encoding and decoding using serde_cbor Enc is the type to encode, Dec is the type to decode
- Framed
- A unified
Stream
andSink
interface to an underlying I/O object, using theEncoder
andDecoder
traits to encode and decode frames. - Framed
Parts - The parts obtained from
Framed::into_parts
. - Framed
Read - A
Stream
of messages decoded from anAsyncRead
. - Framed
Read Parts - The parts obtained from (FramedRead::into_parts).
- Framed
Write - A
Sink
of frames encoded to anAsyncWrite
. - Framed
Write Parts - The parts obtained from
FramedWrite::into_parts
. - Json
Codec - A codec for JSON encoding and decoding using serde_json Enc is the type to encode, Dec is the type to decode
- Length
Codec - A simple
Codec
implementation sending your data by prefixing it by its length. - Lines
Codec - A simple
Codec
implementation that splits up data into lines.
Enums§
- Cbor
Codec Error - JSON Codec error enumeration
- Json
Codec Error - JSON Codec error enumeration