Struct bytes::buf::RingBuf [] [src]

pub struct RingBuf {
    // some 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

fn new(capacity: usize) -> RingBuf

Allocates a new RingBuf with the specified capacity.

fn is_full(&self) -> bool

Returns true if the buf cannot accept any further writes.

fn is_empty(&self) -> bool

Returns true if the buf cannot accept any further reads.

fn capacity(&self) -> usize

Returns the number of bytes that the buf can hold.

fn mark(&mut self)

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.

fn reset(&mut self)

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,

fn clear(&mut self)

Resets all internal state to the initial state.

Trait Implementations

impl Clone for RingBuf

fn clone(&self) -> RingBuf

1.0.0fn clone_from(&mut self, source: &Self)

impl Debug for RingBuf

fn fmt(&self, fmt: &mut Formatter) -> Result

impl Buf for RingBuf

fn remaining(&self) -> usize

fn bytes(&self) -> &[u8]

fn advance(&mut self, cnt: usize)

fn has_remaining(&self) -> bool

fn read_slice(&mut self, dst: &mut [u8]) -> usize

fn read_byte(&mut self) -> Option<u8>

impl MutBuf for RingBuf

fn remaining(&self) -> usize

unsafe fn advance(&mut self, cnt: usize)

unsafe fn mut_bytes(&mut self) -> &mut [u8]

fn has_remaining(&self) -> bool

fn write_slice(&mut self, src: &[u8]) -> usize

fn write_byte(&mut self, byte: u8) -> bool

impl Read for RingBuf

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

1.0.0fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>

1.0.0fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>

1.6.0fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>

1.0.0fn by_ref(&mut self) -> &mut Self

1.0.0fn bytes(self) -> Bytes<Self>

fn chars(self) -> Chars<Self>

1.0.0fn chain<R>(self, next: R) -> Chain<Self, R> where R: Read

1.0.0fn take(self, limit: u64) -> Take<Self>

impl Write for RingBuf

fn write(&mut self, buf: &[u8]) -> Result<usize>

fn flush(&mut self) -> Result<()>

1.0.0fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

1.0.0fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>

1.0.0fn by_ref(&mut self) -> &mut Self

impl Send for RingBuf