Struct tokio_core::io::EasyBuf [] [src]

pub struct EasyBuf { /* fields omitted */ }

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]

Creates a new EasyBuf with no data and the default capacity.

Creates a new EasyBuf with cap capacity.

Returns the number of bytes contained in this EasyBuf.

Returns the inner contents of this EasyBuf as a slice.

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

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

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 this allocation, 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]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl AsRef<[u8]> for EasyBuf
[src]

Performs the conversion.

impl From<Vec<u8>> for EasyBuf
[src]

Performs the conversion.