pub struct BytearrayRingbuffer<const N: usize> { /* private fields */ }Implementations§
Source§impl<const N: usize> BytearrayRingbuffer<N>
impl<const N: usize> BytearrayRingbuffer<N>
Sourcepub const fn free(&self) -> usize
pub const fn free(&self) -> usize
number of bytes available for payload, 8 bytes for header + end are already subtracted
Sourcepub fn push(&mut self, data: &[u8]) -> Result<(), NotEnoughSpaceError>
pub fn push(&mut self, data: &[u8]) -> Result<(), NotEnoughSpaceError>
add element, returns NotEnoughSpaceError if there is not enough space available
Sourcepub fn push_force(&mut self, data: &[u8]) -> Result<(), NotEnoughSpaceError>
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
pub const fn empty(&self) -> bool
Sourcepub fn pop_front(&mut self) -> Option<(&[u8], &[u8])>
pub fn pop_front(&mut self) -> Option<(&[u8], &[u8])>
retrieve the oldest element, removing it from the buffer
Sourcepub fn iter_backwards<'a>(&'a self) -> IterBackwards<'a, N> ⓘ
pub fn iter_backwards<'a>(&'a self) -> IterBackwards<'a, N> ⓘ
iterate over all items, starting with the newest one
Sourcepub fn iter<'a>(&'a self) -> Iter<'a, N> ⓘ
pub fn iter<'a>(&'a self) -> Iter<'a, N> ⓘ
iterate over all items, starting with the oldest one
Sourcepub fn nth_reverse(&self, n: usize) -> Option<(&[u8], &[u8])>
pub fn nth_reverse(&self, n: usize) -> Option<(&[u8], &[u8])>
obtain the n-th entry, starting from the newest entry
Sourcepub fn nth_contiguous(&mut self, n: usize) -> Option<&[u8]>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more