Struct bipbuffer::BipBuffer
[−]
[src]
pub struct BipBuffer<T> { /* fields omitted */ }
A Bip-Buffer object
Methods
impl<T: Default> BipBuffer<T>
[src]
fn new(length: usize) -> BipBuffer<T>
Creates and allocates a new buffer of T
elements
fn clear(&mut self)
Clears all regions and reservations
Data in the underlying buffer is unchanged
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
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
fn read(&mut self) -> Option<&mut [T]>
Retrieves available (committed) data as a contiguous block.
Returns None
if there is no data available
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.
fn committed_len(&self) -> usize
Number of committed elements
This approximates the size of the buffer that will be returned on read()
fn reserved_len(&self) -> usize
Number of reserved elements
This is the amount of available space for writing data to the buffer
fn len(&self) -> usize
Size of the backing store
Uses len() * size_of(T) + 6 * size_of(usize)
memory overall
fn is_empty(&self) -> bool
Whether any space has been reserved or committed in the buffer