dencode/
lib.rs

1#![deny(
2    clippy::all,
3    missing_docs,
4    missing_debug_implementations,
5    rust_2018_idioms,
6    unreachable_pub
7)]
8//! Utilities for encoding and decoding frames using `async/await`.
9//!
10//! Contains adapters to go from streams of bytes, [`AsyncRead`](futures-util::io::AsyncRead)
11//! and [`AsyncWrite`](futures-util::io::AsyncWrite), to framed streams implementing [`Sink`](futures-util::Sink) and [`Stream`](futures-util::Stream).
12//! Framed streams are also known as `transports`.
13//!
14//! ```
15//! # futures::executor::block_on(async move {
16//! use dencode::{Framed, LinesCodec};
17//! use futures::{io::Cursor, TryStreamExt};
18//!
19//! let io = Cursor::new(Vec::new());
20//! let mut framed = Framed::new(io, LinesCodec {});
21//!
22//! while let Some(line) = framed.try_next().await? {
23//!     dbg!(line);
24//! }
25//! # Ok::<_, std::io::Error>(())
26//! # }).unwrap();
27//! ```
28
29pub use bytes::{Buf, BufMut, Bytes, BytesMut};
30
31mod codec;
32pub use codec::{bytes::BytesCodec, lines::LinesCodec};
33
34mod decoder;
35pub use decoder::Decoder;
36
37mod encoder;
38pub use encoder::Encoder;
39
40mod framed;
41pub use framed::Framed;
42
43mod framed_read;
44pub use framed_read::FramedRead;
45
46mod framed_write;
47pub use framed_write::FramedWrite;
48
49mod sink;
50pub use sink::{IterSink, IterSinkExt};
51
52mod fuse;