Struct tokio_util::codec::BytesCodec [−][src]
pub struct BytesCodec(_);
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
impl BytesCodec
[src]
impl BytesCodec
[src]pub fn new() -> BytesCodec
[src]
pub fn new() -> BytesCodec
[src]Creates a new BytesCodec
for shipping around raw bytes.
Trait Implementations
impl Clone for BytesCodec
[src]
impl Clone for BytesCodec
[src]fn clone(&self) -> BytesCodec
[src]
fn clone(&self) -> BytesCodec
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
impl Debug for BytesCodec
[src]
impl Debug for BytesCodec
[src]impl Decoder for BytesCodec
[src]
impl Decoder for BytesCodec
[src]fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<BytesMut>, Error>
[src]
fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<BytesMut>, Error>
[src]Attempts to decode a frame from the provided buffer of bytes. Read more
impl Default for BytesCodec
[src]
impl Default for BytesCodec
[src]fn default() -> BytesCodec
[src]
fn default() -> BytesCodec
[src]Returns the “default value” for a type. Read more
impl Encoder<Bytes> for BytesCodec
[src]
impl Encoder<Bytes> for BytesCodec
[src]impl Hash for BytesCodec
[src]
impl Hash for BytesCodec
[src]impl Ord for BytesCodec
[src]
impl Ord for BytesCodec
[src]impl PartialEq<BytesCodec> for BytesCodec
[src]
impl PartialEq<BytesCodec> for BytesCodec
[src]fn eq(&self, other: &BytesCodec) -> bool
[src]
fn eq(&self, other: &BytesCodec) -> bool
[src]This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &BytesCodec) -> bool
[src]
fn ne(&self, other: &BytesCodec) -> bool
[src]This method tests for !=
.
impl PartialOrd<BytesCodec> for BytesCodec
[src]
impl PartialOrd<BytesCodec> for BytesCodec
[src]fn partial_cmp(&self, other: &BytesCodec) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &BytesCodec) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for BytesCodec
[src]
impl Eq for BytesCodec
[src]
impl StructuralEq for BytesCodec
[src]
impl StructuralPartialEq for BytesCodec
[src]
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
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more