pub struct BipBuffer<T> { /* private fields */ }
Expand description
A Bip-Buffer object
Implementations§
Source§impl<T: Default> BipBuffer<T>
impl<T: Default> BipBuffer<T>
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears all regions and reservations
Data in the underlying buffer is unchanged
Sourcepub fn reserve(&mut self, length: usize) -> Result<&mut [T], Error>
pub fn reserve(&mut self, length: usize) -> Result<&mut [T], Error>
Returns a mutable buffer containing up to length
slots for storing data.
If there is less free space than requested, the buffer size will equal the free space.
Returns Error
if there is no free space
Sourcepub fn commit(&mut self, length: usize)
pub fn commit(&mut self, length: usize)
Commits the data in the reservation, allowing it to be read later
If a length
of 0
is passed in, the reservation will be cleared without making any
other changes
Sourcepub fn read(&mut self) -> Option<&mut [T]>
pub fn read(&mut self) -> Option<&mut [T]>
Retrieves available (committed) data as a contiguous block.
Returns None
if there is no data available
Sourcepub fn decommit(&mut self, length: usize)
pub fn decommit(&mut self, length: usize)
Marks the first length
elements of the available data is seen.
The next time read()
is called, it will not include these elements.
Sourcepub fn committed_len(&self) -> usize
pub fn committed_len(&self) -> usize
Number of committed elements
This approximates the size of the buffer that will be returned on read()
Sourcepub fn reserved_len(&self) -> usize
pub fn reserved_len(&self) -> usize
Number of reserved elements
This is the amount of available space for writing data to the buffer