Struct BipBuffer

Source
pub struct BipBuffer<T> { /* private fields */ }
Expand description

A Bip-Buffer object

Implementations§

Source§

impl<T: Default> BipBuffer<T>

Source

pub fn new(length: usize) -> BipBuffer<T>

Creates and allocates a new buffer of T elements

Source

pub fn clear(&mut self)

Clears all regions and reservations

Data in the underlying buffer is unchanged

Source

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

Source

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

Source

pub fn read(&mut self) -> Option<&mut [T]>

Retrieves available (committed) data as a contiguous block.

Returns None if there is no data available

Source

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.

Source

pub fn committed_len(&self) -> usize

Number of committed elements

This approximates the size of the buffer that will be returned on read()

Source

pub fn reserved_len(&self) -> usize

Number of reserved elements

This is the amount of available space for writing data to the buffer

Source

pub fn len(&self) -> usize

Size of the backing store

Uses len() * size_of(T) + 6 * size_of(usize) memory overall

Source

pub fn is_empty(&self) -> bool

Whether any space has been reserved or committed in the buffer

Trait Implementations§

Source§

impl<T: Debug> Debug for BipBuffer<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for BipBuffer<T>

§

impl<T> RefUnwindSafe for BipBuffer<T>
where T: RefUnwindSafe,

§

impl<T> Send for BipBuffer<T>
where T: Send,

§

impl<T> Sync for BipBuffer<T>
where T: Sync,

§

impl<T> Unpin for BipBuffer<T>
where T: Unpin,

§

impl<T> UnwindSafe for BipBuffer<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.