Trait Filter

Source
pub trait Filter<const N: usize>: Sized {
    type Output<T>;

    // Required method
    fn filter<S: StateFnMut<N, Output = bool>>(self, f: S) -> Self::Output<S>;

    // Provided methods
    fn every(self, n: usize) -> Self::Output<impl StateFnMut<N, Output = bool>> { ... }
    fn every_offset(
        self,
        n: usize,
        offset: usize,
    ) -> Self::Output<impl StateFnMut<N, Output = bool>> { ... }
    fn separated_by(
        self,
        delta: f64,
    ) -> Self::Output<impl StateFnMut<N, Output = bool>> { ... }
    fn in_range(
        self,
        interval: impl RangeBounds<f64>,
    ) -> Self::Output<impl StateFnMut<N, Output = bool>> { ... }
    fn once(self) -> Self::Output<impl StateFnMut<N, Output = bool>> { ... }
    fn take(self, n: usize) -> Self::Output<impl StateFnMut<N, Output = bool>> { ... }
    fn times(
        self,
        range: impl RangeBounds<usize>,
    ) -> Self::Output<impl StateFnMut<N, Output = bool>> { ... }
}
Expand description

Trait manages adding filtering functions to a vector field of a class, such as crate::Event and crate::Loc.

Required Associated Types§

Source

type Output<T>

the type of self after application of filter method

Required Methods§

Source

fn filter<S: StateFnMut<N, Output = bool>>(self, f: S) -> Self::Output<S>

push a new [StateFn] which returns bool to self and return self for chained syntax.

Provided Methods§

Source

fn every(self, n: usize) -> Self::Output<impl StateFnMut<N, Output = bool>>

Push a new filtering function, which returns true every nth invocation, including the first invocation. The effect of that filtration, is that only every ’n’th event is remained.

Source

fn every_offset( self, n: usize, offset: usize, ) -> Self::Output<impl StateFnMut<N, Output = bool>>

Push a new filtering function, which returns true every nth invocation, starting with (offset % n)th invocation, such that with offset = 0 it is equivalent to Filter::every. The effect of that filtration, is that only every ’n’th event is remained, starting from offsetth event (zero-based).

Source

fn separated_by( self, delta: f64, ) -> Self::Output<impl StateFnMut<N, Output = bool>>

Push a new filtering function, which remembers the last time it returned true and returns true only if the state time is advanced at least by delta (inclusive) since the last returning true. The effect is that after filtration events are guaranteed to be separated in time by at least delta.

Source

fn in_range( self, interval: impl RangeBounds<f64>, ) -> Self::Output<impl StateFnMut<N, Output = bool>>

Push a new filtering function, that filters all events, the state time of which is not contained in a given f64 range.

Source

fn once(self) -> Self::Output<impl StateFnMut<N, Output = bool>>

Push a filtering function, that returns true on the first invocation and then always returns false. Equivalent in behaviour to [Filter::take(1)].

Source

fn take(self, n: usize) -> Self::Output<impl StateFnMut<N, Output = bool>>

Push a filtering function, that returns true on the first n invocations and then always returns false. Equivalent in behaviour to [Filter::times(0..n)].

Source

fn times( self, range: impl RangeBounds<usize>, ) -> Self::Output<impl StateFnMut<N, Output = bool>>

Push a filtering function, that returns true if the number of the invocation of that function is in range.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<const N: usize, const MUT: bool, Subdivision, Callback, Output, Stream, Filter: HList + Append> Filter<N> for Event<N, MUT, Subdivision, Callback, Output, Stream, Filter>

Source§

type Output<T> = Event<N, MUT, Subdivision, Callback, Output, Stream, <Filter as Append>::Output<T>>