Struct iqdb::BytesCodec
pub struct BytesCodec(/* private fields */);
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
impl BytesCodec
pub fn new() -> BytesCodec
pub fn new() -> BytesCodec
Creates a new BytesCodec
for shipping around raw bytes.
Trait Implementations§
§impl Clone for BytesCodec
impl Clone for BytesCodec
§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 more§impl Debug for BytesCodec
impl Debug for BytesCodec
§impl Decoder for BytesCodec
impl Decoder for BytesCodec
§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
§fn decode_eof(
&mut self,
buf: &mut BytesMut
) -> Result<Option<Self::Item>, Self::Error>
fn decode_eof( &mut self, buf: &mut BytesMut ) -> Result<Option<Self::Item>, Self::Error>
A default method available to be called when there are no more bytes
available to be read from the underlying I/O. Read more
§impl Default for BytesCodec
impl Default for BytesCodec
§fn default() -> BytesCodec
fn default() -> BytesCodec
Returns the “default value” for a type. Read more
§impl Encoder<Bytes> for BytesCodec
impl Encoder<Bytes> for BytesCodec
§impl Encoder<BytesMut> for BytesCodec
impl Encoder<BytesMut> for BytesCodec
§impl Hash for BytesCodec
impl Hash for BytesCodec
§impl Ord for BytesCodec
impl Ord for BytesCodec
§impl PartialEq for BytesCodec
impl PartialEq for BytesCodec
§fn eq(&self, other: &BytesCodec) -> bool
fn eq(&self, other: &BytesCodec) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.§impl PartialOrd for BytesCodec
impl PartialOrd for BytesCodec
§fn partial_cmp(&self, other: &BytesCodec) -> Option<Ordering>
fn partial_cmp(&self, other: &BytesCodec) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
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§
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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.