[−][src]Struct bytes::RingBuf
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 RingBufpub 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]
fn remaining(&self) -> usize
[src]
fn bytes(&self) -> &[u8]
[src]
fn advance(&mut self, cnt: usize)
[src]
fn has_remaining(&self) -> bool
[src]
fn read_slice(&mut self, dst: &mut [u8]) -> usize
[src]
fn read_byte(&mut self) -> Option<u8>
[src]
impl MutBuf for RingBuf
[src]
fn remaining(&self) -> usize
[src]
unsafe fn advance(&mut self, cnt: usize)
[src]
unsafe fn mut_bytes(&mut self) -> &mut [u8]
[src]
fn has_remaining(&self) -> bool
[src]
fn write_slice(&mut self, src: &[u8]) -> usize
[src]
fn write_byte(&mut self, byte: u8) -> bool
[src]
impl Send for RingBuf
[src]
impl Clone for RingBuf
[src]
ⓘImportant traits for RingBuffn clone(&self) -> RingBuf
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for RingBuf
[src]
impl Read for RingBuf
[src]
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
[src]
fn read_vectored(&mut self, bufs: &mut [IoSliceMut]) -> Result<usize, Error>
1.36.0[src]
unsafe fn initializer(&self) -> Initializer
[src]
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
1.0.0[src]
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
fn bytes(self) -> Bytes<Self>
1.0.0[src]
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
impl Write for RingBuf
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize, Error>
1.36.0[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[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]
B: Buf,
impl<B> MutBufExt for B where
B: MutBuf,
[src]
B: MutBuf,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,