Struct tokio_util::codec::BytesCodec
source · [−]pub struct BytesCodec(_);
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
sourceimpl BytesCodec
impl BytesCodec
sourcepub fn new() -> BytesCodec
pub fn new() -> BytesCodec
Creates a new BytesCodec
for shipping around raw bytes.
Trait Implementations
sourceimpl Clone for BytesCodec
impl Clone for BytesCodec
sourcefn clone(&self) -> BytesCodec
fn clone(&self) -> BytesCodec
Returns a copy of the value. Read more
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for BytesCodec
impl Debug for BytesCodec
sourceimpl Decoder for BytesCodec
impl Decoder for BytesCodec
sourcefn 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
sourceimpl Default for BytesCodec
impl Default for BytesCodec
sourcefn default() -> BytesCodec
fn default() -> BytesCodec
Returns the “default value” for a type. Read more
sourceimpl Encoder<Bytes> for BytesCodec
impl Encoder<Bytes> for BytesCodec
sourceimpl Encoder<BytesMut> for BytesCodec
impl Encoder<BytesMut> for BytesCodec
sourceimpl Hash for BytesCodec
impl Hash for BytesCodec
sourceimpl Ord for BytesCodec
impl Ord for BytesCodec
sourcefn cmp(&self, other: &BytesCodec) -> Ordering
fn cmp(&self, other: &BytesCodec) -> Ordering
1.21.0 · sourceconst fn max(self, other: Self) -> Self
const fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourceconst fn min(self, other: Self) -> Self
const fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<BytesCodec> for BytesCodec
impl PartialEq<BytesCodec> for BytesCodec
sourcefn eq(&self, other: &BytesCodec) -> bool
fn eq(&self, other: &BytesCodec) -> bool
sourceimpl PartialOrd<BytesCodec> for BytesCodec
impl PartialOrd<BytesCodec> for BytesCodec
sourcefn partial_cmp(&self, other: &BytesCodec) -> Option<Ordering>
fn partial_cmp(&self, other: &BytesCodec) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for BytesCodec
impl Eq for BytesCodec
impl StructuralEq for BytesCodec
impl StructuralPartialEq for BytesCodec
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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more