irox_stats::windows

Struct TimeWindow

Source
pub struct TimeWindow<T> { /* private fields */ }
Available on crate feature std only.
Expand description

This struct is a rolling time window for the provided data. It will automatically “throw out” data that falls outside (older) than the most recent data provided. It does NOT do any downsampling or processing of the data.

Implementations§

Source§

impl<T: Copy> TimeWindow<T>

Source

pub fn new(window_duration: Duration) -> Self

Source

pub fn insert(&mut self, timestamp: Timestamp<T>, value: f64)

Source

pub fn clear(&mut self)

Source

pub fn add_sample(&mut self, samp: Sample<T>)

Source

pub fn first_key_value(&self) -> Option<(&Timestamp<T>, &f64)>

returns the first (earliest, oldest) sample provided

Source

pub fn last_key_value(&self) -> Option<(&Timestamp<T>, &f64)>

returns the last (latest, newest) sample provided

Source

pub fn len(&self) -> usize

number of samples currently stored.

Source

pub fn is_empty(&self) -> bool

Source

pub fn data(&self) -> Vec<f64>

Copies the set of the data out

Source

pub fn iter(&self) -> impl Iterator<Item = (&Timestamp<T>, &f64)> + Clone

Source

pub fn map_data<V, F: Fn((&Timestamp<T>, &f64)) -> V>(&self, fun: F) -> Vec<V>

Auto Trait Implementations§

§

impl<T> Freeze for TimeWindow<T>

§

impl<T> RefUnwindSafe for TimeWindow<T>
where T: RefUnwindSafe,

§

impl<T> Send for TimeWindow<T>
where T: Send,

§

impl<T> Sync for TimeWindow<T>
where T: Sync,

§

impl<T> Unpin for TimeWindow<T>

§

impl<T> UnwindSafe for TimeWindow<T>
where T: RefUnwindSafe,

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> MaybeInto<U> for T
where U: MaybeFrom<T>,

Source§

fn maybe_into(self) -> Option<U>

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.