Struct asynchronous_codec::BytesCodec
source · pub struct BytesCodec;
Expand description
A simple codec that ships bytes around
Example
use bytes::Bytes;
use futures::{SinkExt, TryStreamExt};
use futures::io::Cursor;
use asynchronous_codec::{BytesCodec, Framed};
let mut buf = vec![];
// Cursor implements AsyncRead and AsyncWrite
let cur = Cursor::new(&mut buf);
let mut framed = Framed::new(cur, BytesCodec);
framed.send(Bytes::from("Hello World!")).await?;
while let Some(bytes) = framed.try_next().await? {
dbg!(bytes);
}