16 unstable releases (3 breaking)
0.4.1 | Jun 21, 2020 |
---|---|
0.4.0 | Jan 26, 2020 |
0.3.4 | Dec 14, 2019 |
0.3.3 | Nov 29, 2019 |
0.2.5 | Jul 22, 2019 |
#931 in Asynchronous
43,096 downloads per month
Used in fewer than 15 crates
42KB
872 lines
futures_codec
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.
Example
use futures_codec::{LinesCodec, Framed};
async fn main() {
// let stream = ...
let mut framed = Framed::new(stream, LinesCodec {});
while let Some(line) = framed.try_next().await.unwrap() {
println!("{:?}", line);
}
}
lib.rs
:
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 futures_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);
}
Dependencies
~2.3–3MB
~65K SLoC