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 dencode::{Framed, LinesCodec};
use futures::{io::Cursor, TryStreamExt};
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.
- Framed
- A unified
Stream
andSink
interface to an underlying I/O object, using theEncoder
andDecoder
traits to encode and decode frames. - Framed
Read - A
Stream
of messages decoded from anAsyncRead
. - Framed
Write - A
Sink
of frames encoded to anAsyncWrite
. - Lines
Codec - A simple
Codec
implementation that splits up data into lines.
Traits§
- Buf
- Read bytes from a buffer.
- BufMut
- A trait for values that provide sequential write access to bytes.
- Decoder
- Decoding of frames via buffers, for use with
FramedRead
. - Encoder
- Encoding of messages as bytes, for use with
FramedWrite
. - Iter
Sink - An
IterSink
is a value into which other values can be sent. - Iter
Sink Ext - An extension trait for
IterSink
s that provides a few convenient functions.