LineBuffer

Struct LineBuffer 

Source
pub struct LineBuffer<T, B>
where T: Debug, B: ArrayLength<Entry<T>>,
{ /* private fields */ }
Expand description

Circular Line Buffer

Implementations§

Source§

impl<T, B> LineBuffer<T, B>
where T: Debug, B: ArrayLength<Entry<T>>,

Source

pub fn new(max: usize) -> Self

Create new circular buffer of defined data size (bytes)

Note that this is not the amount of entries (lines). LineBuffer will wrap after reaching max bytes or the max amount of lines specified.

Source

pub fn iter(&self) -> Iter<'_, T>

Returns an iterator over the elements

Note that the first iteration step has some overhead to skip invalid entries.

Source

pub fn elements(&self) -> usize

Total amount of inserted elements

Source

pub fn capacity(&self) -> usize

Capacity of elements (lines)

Source

pub fn capacity_bytes(&self) -> usize

Capacity of total bytes

Note that due to fragmentation it is not trivially possible to get the amount of free bytes

Source

pub fn get(&self, idx: usize) -> Option<(&[u8], &T)>

Get element at index, idx counting up since first element inserted.

Source

pub fn insert(&mut self, element: &[u8], addition: T)

Insert element at the front and an additional value, which can be used as flag

Auto Trait Implementations§

§

impl<T, B> Freeze for LineBuffer<T, B>
where <B as ArrayLength<Entry<T>>>::ArrayType: Freeze,

§

impl<T, B> RefUnwindSafe for LineBuffer<T, B>

§

impl<T, B> Send for LineBuffer<T, B>
where T: Send,

§

impl<T, B> Sync for LineBuffer<T, B>
where T: Sync,

§

impl<T, B> Unpin for LineBuffer<T, B>
where <B as ArrayLength<Entry<T>>>::ArrayType: Unpin,

§

impl<T, B> UnwindSafe for LineBuffer<T, B>

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> Same for T

Source§

type Output = T

Should always be Self
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.