pub struct RingBuf { /* private fields */ }Expand description
A data structure that uses a single, fixed-size buffer as if it were connected end-to-end
Implementations§
Source§impl RingBuf
impl RingBuf
Sourcepub fn with_capacity(value: NonZeroUsize) -> Self
pub fn with_capacity(value: NonZeroUsize) -> Self
Create a new RingBuf object with provided capacity.
The provided capacity must be NonZeroUsize.
Sourcepub fn remaining_mut(&self) -> usize
pub fn remaining_mut(&self) -> usize
Returns the number of bytes that can be written from the current position until the end of the buffer is reached.
Sourcepub fn chunk_mut(&mut self) -> &mut [u8] ⓘ
pub fn chunk_mut(&mut self) -> &mut [u8] ⓘ
Returns a mutable slice starting at the write pointer,
the length may shorter than remaining_mut.
Sourcepub fn chunk(&self) -> &[u8] ⓘ
pub fn chunk(&self) -> &[u8] ⓘ
Returns a immutable slice starting at the read pointer,
the length may shorter than remaining.
Sourcepub fn advance_mut(&mut self, offset: usize)
pub fn advance_mut(&mut self, offset: usize)
Advance the innner write cursor of this RingBuf.
if the offset value > remaining_mut will cause an panic.
Sourcepub fn advance(&mut self, offset: usize)
pub fn advance(&mut self, offset: usize)
Advance the innner read cursor of this RingBuf.
if the offset value > remaining will cause an panic.