Struct winvec::WinVec[][src]

pub struct WinVec<T>(_, _);

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

impl<T: Clone> Clone for WinVec<T>[src]

impl<'a, T: Clone> IntoIterator for WinVec<T>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = IntoIter<Self::Item>

Which kind of iterator are we turning this into?

Auto Trait Implementations

impl<T> RefUnwindSafe for WinVec<T> where
    T: RefUnwindSafe

impl<T> Send for WinVec<T> where
    T: Send

impl<T> Sync for WinVec<T> where
    T: Sync

impl<T> Unpin for WinVec<T> where
    T: Unpin

impl<T> UnwindSafe for WinVec<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.