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 RefUnwindSafe for BytesCodec
impl Send for BytesCodec
impl Sync for BytesCodec
impl Unpin for BytesCodec
impl UnwindSafe for BytesCodec
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more