async-codec-lite 0.0.2

Adaptors from AsyncRead/AsyncWrite to Stream/Sink using futures.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use async_codec_lite::{BytesCodec, Framed};
use futures_lite::future::block_on;
use futures_util::{io::Cursor, stream::TryStreamExt};

#[test]
fn decodes() {
    let mut buf = [0u8; 32];
    let expected = buf;
    let cur = Cursor::new(&mut buf[..]);
    let mut framed = Framed::new(cur, BytesCodec {});

    let read = block_on(framed.try_next()).unwrap().unwrap();
    assert_eq!(&read[..], &expected[..]);

    assert!(block_on(framed.try_next()).unwrap().is_none());
}