Struct tokio_core::io::EasyBuf
[−]
[src]
pub struct EasyBuf { /* fields omitted */ }
: moved to the tokio-io
crate
A reference counted buffer of bytes.
An EasyBuf
is a representation of a byte buffer where sub-slices of it can
be handed out efficiently, each with a 'static
lifetime which keeps the
data alive. The buffer also supports mutation but may require bytes to be
copied to complete the operation.
Methods
impl EasyBuf
[src]
fn new() -> EasyBuf
: moved to the tokio-io
crate
Creates a new EasyBuf with no data and the default capacity.
fn with_capacity(cap: usize) -> EasyBuf
: moved to the tokio-io
crate
Creates a new EasyBuf with cap
capacity.
fn len(&self) -> usize
: moved to the tokio-io
crate
Returns the number of bytes contained in this EasyBuf
.
fn as_slice(&self) -> &[u8]
: moved to the tokio-io
crate
Returns the inner contents of this EasyBuf
as a slice.
fn split_off(&mut self, at: usize) -> EasyBuf
: moved to the tokio-io
crate
Splits the buffer into two at the given index.
Afterwards self
contains elements [0, at)
, and the returned EasyBuf
contains elements [at, len)
.
This is an O(1) operation that just increases the reference count and sets a few indexes.
Panics
Panics if at > len
fn drain_to(&mut self, at: usize) -> EasyBuf
: moved to the tokio-io
crate
Splits the buffer into two at the given index.
Afterwards self
contains elements [at, len)
, and the returned EasyBuf
contains elements [0, at)
.
This is an O(1) operation that just increases the reference count and sets a few indexes.
Panics
Panics if at > len
fn get_mut(&mut self) -> EasyBufMut
: moved to the tokio-io
crate
Returns a mutable reference to the underlying growable buffer of bytes.
If this EasyBuf
is the only instance pointing at the underlying buffer
of bytes, a direct mutable reference will be returned. Otherwise the
contents of this EasyBuf
will be reallocated in a fresh Vec<u8>
allocation with the same capacity as an EasyBuf
created with EasyBuf::new()
,
and that allocation will be returned.
This operation is not O(1) as it may clone the entire contents of this buffer.
The returned EasyBufMut
type implement Deref
and DerefMut
to
Vec<u8>
can the byte buffer can be manipulated using the standard
Vec<u8>
methods.
Trait Implementations
impl Clone for EasyBuf
[src]
fn clone(&self) -> EasyBuf
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Eq for EasyBuf
[src]
impl AsRef<[u8]> for EasyBuf
[src]
impl From<Vec<u8>> for EasyBuf
[src]
impl<T: AsRef<[u8]>> PartialEq<T> for EasyBuf
[src]
fn eq(&self, other: &T) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl Ord for EasyBuf
[src]
fn cmp(&self, other: &Self) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
ord_max_min
)Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
ord_max_min
)Compares and returns the minimum of two values. Read more
impl<T: AsRef<[u8]>> PartialOrd<T> for EasyBuf
[src]
fn partial_cmp(&self, other: &T) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Hash for EasyBuf
[src]
fn hash<H: Hasher>(&self, state: &mut H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more