[][src]Struct bytes::RingBuf

pub struct RingBuf { /* fields omitted */ }

Buf backed by a continous chunk of memory. Maintains a read cursor and a write cursor. When reads and writes reach the end of the allocated buffer, wraps around to the start.

This type is suited for use cases where reads and writes are intermixed.

Methods

impl RingBuf[src]

Important traits for RingBuf
pub fn new(capacity: usize) -> RingBuf[src]

Allocates a new RingBuf with the specified capacity.

pub fn is_full(&self) -> bool[src]

Returns true if the buf cannot accept any further writes.

pub fn is_empty(&self) -> bool[src]

Returns true if the buf cannot accept any further reads.

pub fn capacity(&self) -> usize[src]

Returns the number of bytes that the buf can hold.

pub fn mark(&mut self)[src]

Marks the current read location.

Together with reset, this can be used to read from a section of the buffer multiple times. The mark will be cleared if it is overwritten during a write.

pub fn reset(&mut self)[src]

Resets the read position to the previously marked position.

Together with mark, this can be used to read from a section of the buffer multiple times.

Panics

This method will panic if no mark has been set,

pub fn clear(&mut self)[src]

Resets all internal state to the initial state.

Trait Implementations

impl Buf for RingBuf[src]

impl MutBuf for RingBuf[src]

impl Send for RingBuf[src]

impl Clone for RingBuf[src]

impl Debug for RingBuf[src]

impl Read for RingBuf[src]

impl Write for RingBuf[src]

Auto Trait Implementations

impl Sync for RingBuf

impl Unpin for RingBuf

impl UnwindSafe for RingBuf

impl RefUnwindSafe for RingBuf

Blanket Implementations

impl<B> BufExt for B where
    B: Buf
[src]

impl<B> MutBufExt for B where
    B: MutBuf
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]