Resampler

Struct Resampler 

Source
pub struct Resampler<T: Div<Output = T> + Sum + PartialOrd + FromPrimitive + Default + Debug, S: Sample<Value = T>> { /* private fields */ }
Expand description

The Resampler struct is used to resample a time series of samples. It stores the samples in a buffer and resamples the samples in the buffer when the resample method is called. A resampler can be configured with a resampling function and a resampling interval.

Implementations§

Source§

impl<T: Div<Output = T> + Sum + PartialOrd + FromPrimitive + Default + Debug, S: Sample<Value = T>> Resampler<T, S>

Source

pub fn new( interval: TimeDelta, resampling_function: ResamplingFunction<T, S>, max_age_in_intervals: i32, start: DateTime<Utc>, first_timestamp: bool, ) -> Self

Creates a new Resampler with the given resampling interval and resampling function.

Source

pub fn push(&mut self, sample: S)

Adds a sample to the buffer.

Source

pub fn buffer(&self) -> &Vec<S>

Returns a reference to the buffer.

Source

pub fn resample(&mut self, end: DateTime<Utc>) -> Vec<S>

Resamples the samples in the buffer and returns the resampled samples until the given end time.

Source

pub fn resample_now(&mut self) -> Vec<S>

Resamples the samples in the buffer and returns the resampled samples until now.

Trait Implementations§

Source§

impl<T: Debug + Div<Output = T> + Sum + PartialOrd + FromPrimitive + Default + Debug, S: Debug + Sample<Value = T>> Debug for Resampler<T, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default + Div<Output = T> + Sum + PartialOrd + FromPrimitive + Default + Debug, S: Default + Sample<Value = T>> Default for Resampler<T, S>

Source§

fn default() -> Resampler<T, S>

Returns the “default value” for a type. Read more
Source§

impl<T: Div<Output = T> + Sum + PartialOrd + FromPrimitive + Default + Debug, S: Sample<Value = T>> Extend<S> for Resampler<T, S>

Source§

fn extend<I: IntoIterator<Item = S>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more

Auto Trait Implementations§

§

impl<T, S> Freeze for Resampler<T, S>

§

impl<T, S> !RefUnwindSafe for Resampler<T, S>

§

impl<T, S> Send for Resampler<T, S>
where S: Send,

§

impl<T, S> Sync for Resampler<T, S>
where S: Sync,

§

impl<T, S> Unpin for Resampler<T, S>
where S: Unpin,

§

impl<T, S> !UnwindSafe for Resampler<T, S>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.