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);
}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BytesCodec
impl RefUnwindSafe for BytesCodec
impl Send for BytesCodec
impl Sync for BytesCodec
impl Unpin for BytesCodec
impl UnwindSafe for BytesCodec
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more