Skip to main content

BytearrayRingbuffer

Struct BytearrayRingbuffer 

Source
pub struct BytearrayRingbuffer<const N: usize> { /* private fields */ }

Implementations§

Source§

impl<const N: usize> BytearrayRingbuffer<N>

Source

pub const fn new() -> Self

create empty BytearrayRingbuffer

Source

pub const fn free(&self) -> usize

number of bytes available for payload, 8 bytes for header + end are already subtracted

Source

pub fn push(&mut self, data: &[u8]) -> Result<(), NotEnoughSpaceError>

add element, returns NotEnoughSpaceError if there is not enough space available

Source

pub fn push_force(&mut self, data: &[u8]) -> Result<(), NotEnoughSpaceError>

add element, discards oldest elements until data fits. Only when data is too large to fit the buffer (ie data.len() > N - 8), returns NotEnoughSpaceError

Source

pub const fn empty(&self) -> bool

Source

pub fn pop_front(&mut self) -> Option<(&[u8], &[u8])>

retrieve the oldest element, removing it from the buffer

Source

pub fn iter_backwards<'a>(&'a self) -> IterBackwards<'a, N>

iterate over all items, starting with the newest one

Source

pub fn iter<'a>(&'a self) -> Iter<'a, N>

iterate over all items, starting with the oldest one

Source

pub const fn count(&self) -> usize

return the number of entries

Source

pub fn nth(&self, n: usize) -> Option<(&[u8], &[u8])>

obtain the n-th entry

Source

pub fn nth_reverse(&self, n: usize) -> Option<(&[u8], &[u8])>

obtain the n-th entry, starting from the newest entry

Source

pub fn nth_contiguous(&mut self, n: usize) -> Option<&[u8]>

obtain the n-th entry, rolling the buffer around in case the element wraps around at the end of the buffer

Trait Implementations§

Source§

impl<const N: usize> Default for BytearrayRingbuffer<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const N: usize> Freeze for BytearrayRingbuffer<N>

§

impl<const N: usize> RefUnwindSafe for BytearrayRingbuffer<N>

§

impl<const N: usize> Send for BytearrayRingbuffer<N>

§

impl<const N: usize> Sync for BytearrayRingbuffer<N>

§

impl<const N: usize> Unpin for BytearrayRingbuffer<N>

§

impl<const N: usize> UnwindSafe for BytearrayRingbuffer<N>

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.