Struct winvec::WinVec [−][src]
Windowed Vector
A Collection that purges keys based on a fixed TTL.
Useful for rolling windows and other time based collections/caches.
We purge old keys on read, rather than on insert.
You can specify the duration via with_duration()
.
Add elements with push
or push_with_timestamp
.
View elements via iter
and into_iter
Implementations
impl<'a, T> WinVec<T>
[src]
pub fn with_duration(dur: Duration) -> Self
[src]
Create a new Windowed Vector with a set duration
pub fn push(&mut self, el: T)
[src]
Push an element into the windowed array
pub fn push_with_timestamp(&mut self, el: T, instant: Instant)
[src]
Push an element with a specified timestamp
pub fn from_vec(vec: Vec<T>, dur: Duration) -> Self
[src]
pub fn duration(&self) -> Duration
[src]
impl<'a, T: Clone> WinVec<T>
[src]
pub fn len(&mut self) -> usize
[src]
Returns the number of elements within the collection. We purge and then return the new length.
pub fn iter(&'a mut self) -> impl 'a + Iterator<Item = T>
[src]
Purges & Returns an Interator of the elements
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for WinVec<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for WinVec<T> where
T: Send,
T: Send,
impl<T> Sync for WinVec<T> where
T: Sync,
T: Sync,
impl<T> Unpin for WinVec<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for WinVec<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,