irox_stats::windows

Struct BinStatistics

Source
pub struct BinStatistics<V, I, R> {
    pub bin_width: R,
    pub bins: BTreeMap<i64, WindowBin<V, I, R>>,
    pub anchor: Option<I>,
}
Available on crate feature std only.
Expand description

Time series data binning. Initialize it with a bin width and it will downsample/re-bin your data providing each bin as a WindowBin

Fields§

§bin_width: R§bins: BTreeMap<i64, WindowBin<V, I, R>>§anchor: Option<I>

Implementations§

Source§

impl<T: Copy> BinStatistics<f64, Timestamp<T>, Duration>

Source

pub fn new(bin_width: Duration) -> Self

Source

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

Process and insert a sample into it’s bin. Returns a reference to the bin in which it was inserted with the latest data.

Source

pub fn remove_data_before(&mut self, timestamp: Timestamp<T>)

Garbage collection - remove all data older than the specified timestamp’s bin.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn iter( &self, ) -> impl Iterator<Item = (&i64, &WindowBin<f64, Timestamp<T>, Duration>)>

Auto Trait Implementations§

§

impl<V, I, R> Freeze for BinStatistics<V, I, R>
where R: Freeze, I: Freeze,

§

impl<V, I, R> RefUnwindSafe for BinStatistics<V, I, R>

§

impl<V, I, R> Send for BinStatistics<V, I, R>
where R: Send, I: Send, V: Send,

§

impl<V, I, R> Sync for BinStatistics<V, I, R>
where R: Sync, I: Sync, V: Sync,

§

impl<V, I, R> Unpin for BinStatistics<V, I, R>
where R: Unpin, I: Unpin,

§

impl<V, I, R> UnwindSafe for BinStatistics<V, I, R>

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.