pub struct BytesCodec(/* private fields */);
Available on crate feature
codec
only.Expand description
A simple Decoder
and Encoder
implementation that just ships bytes around.
§Example
Turn an AsyncRead
into a stream of Result<
BytesMut
,
Error
>
.
use tokio::fs::File;
use tokio::io::AsyncRead;
use tokio_util::codec::{FramedRead, BytesCodec};
let my_async_read = File::open("filename.txt").await?;
let my_stream_of_bytes = FramedRead::new(my_async_read, BytesCodec::new());
Implementations§
Source§impl BytesCodec
impl BytesCodec
Sourcepub fn new() -> BytesCodec
pub fn new() -> BytesCodec
Creates a new BytesCodec
for shipping around raw bytes.
Trait Implementations§
Source§impl Clone for BytesCodec
impl Clone for BytesCodec
Source§fn clone(&self) -> BytesCodec
fn clone(&self) -> BytesCodec
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for BytesCodec
impl Debug for BytesCodec
Source§impl Decoder for BytesCodec
impl Decoder for BytesCodec
Source§fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<BytesMut>, Error>
fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<BytesMut>, Error>
Attempts to decode a frame from the provided buffer of bytes. Read more
Source§impl Default for BytesCodec
impl Default for BytesCodec
Source§fn default() -> BytesCodec
fn default() -> BytesCodec
Returns the “default value” for a type. Read more
Source§impl Encoder<Bytes> for BytesCodec
impl Encoder<Bytes> for BytesCodec
Source§impl Encoder<BytesMut> for BytesCodec
impl Encoder<BytesMut> for BytesCodec
Source§impl Hash for BytesCodec
impl Hash for BytesCodec
Source§impl Ord for BytesCodec
impl Ord for BytesCodec
Source§fn cmp(&self, other: &BytesCodec) -> Ordering
fn cmp(&self, other: &BytesCodec) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for BytesCodec
impl PartialEq for BytesCodec
Source§impl PartialOrd for BytesCodec
impl PartialOrd for BytesCodec
impl Copy for BytesCodec
impl Eq for BytesCodec
impl StructuralPartialEq for BytesCodec
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