pub struct ArrayStorage<T, const SIZE: usize, const CAPACITY: usize>{ /* private fields */ }
Expand description
A highly optimized fixed-size array-based sliding window implementation
§Type Parameters
T
- The type of elements stored in the windowSIZE
- The size of the sliding windowCAPACITY
- The total capacity of the underlying array
§Implementation Note
Uses a fixed-size array with constant memory footprint. The window slides through the array using head and tail pointers, with rewind operations when needed.
Implementations§
Source§impl<T, const SIZE: usize, const CAPACITY: usize> ArrayStorage<T, SIZE, CAPACITY>
impl<T, const SIZE: usize, const CAPACITY: usize> ArrayStorage<T, SIZE, CAPACITY>
Trait Implementations§
Source§impl<T, const SIZE: usize, const CAPACITY: usize> Default for ArrayStorage<T, SIZE, CAPACITY>
impl<T, const SIZE: usize, const CAPACITY: usize> Default for ArrayStorage<T, SIZE, CAPACITY>
Source§impl<T, const SIZE: usize, const CAPACITY: usize> WindowStorage<T> for ArrayStorage<T, SIZE, CAPACITY>
impl<T, const SIZE: usize, const CAPACITY: usize> WindowStorage<T> for ArrayStorage<T, SIZE, CAPACITY>
Source§fn first(&self) -> Result<T, String>
fn first(&self) -> Result<T, String>
Returns the first (oldest) element in the sliding window
§Returns
Ok(T)
- The first element in the windowErr(String)
- If the window is empty
Source§fn last(&self) -> Result<T, String>
fn last(&self) -> Result<T, String>
Returns the last (newest) element in the sliding window
§Returns
Ok(T)
- The last element in the windowErr(String)
- If the window is not yet filled
Source§fn get_slice(&self) -> &[T]
fn get_slice(&self) -> &[T]
Returns a slice of the current window contents
§Returns
&[T]
- A slice containing the current window elements
Auto Trait Implementations§
impl<T, const SIZE: usize, const CAPACITY: usize> Freeze for ArrayStorage<T, SIZE, CAPACITY>
impl<T, const SIZE: usize, const CAPACITY: usize> RefUnwindSafe for ArrayStorage<T, SIZE, CAPACITY>
impl<T, const SIZE: usize, const CAPACITY: usize> Send for ArrayStorage<T, SIZE, CAPACITY>
impl<T, const SIZE: usize, const CAPACITY: usize> Sync for ArrayStorage<T, SIZE, CAPACITY>
impl<T, const SIZE: usize, const CAPACITY: usize> Unpin for ArrayStorage<T, SIZE, CAPACITY>
impl<T, const SIZE: usize, const CAPACITY: usize> UnwindSafe for ArrayStorage<T, SIZE, CAPACITY>
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