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§
Required Methods§
Sourcefn filter<S: StateFnMut<N, Output = bool>>(self, f: S) -> Self::Output<S>
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§
Sourcefn every(self, n: usize) -> Self::Output<impl StateFnMut<N, Output = bool>>
fn every(self, n: usize) -> Self::Output<impl StateFnMut<N, Output = bool>>
Push a new filtering function, which returns true
every n
th invocation, including the
first invocation.
The effect of that filtration, is that only every ’n’th event is remained.
Sourcefn every_offset(
self,
n: usize,
offset: usize,
) -> Self::Output<impl StateFnMut<N, Output = bool>>
fn every_offset( self, n: usize, offset: usize, ) -> Self::Output<impl StateFnMut<N, Output = bool>>
Push a new filtering function, which returns true
every n
th 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
offset
th event (zero-based).
Sourcefn separated_by(
self,
delta: f64,
) -> Self::Output<impl StateFnMut<N, Output = bool>>
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.
Sourcefn in_range(
self,
interval: impl RangeBounds<f64>,
) -> Self::Output<impl StateFnMut<N, Output = bool>>
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.
Sourcefn once(self) -> Self::Output<impl StateFnMut<N, Output = bool>>
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)].
Sourcefn take(self, n: usize) -> Self::Output<impl StateFnMut<N, Output = bool>>
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)].
Sourcefn times(
self,
range: impl RangeBounds<usize>,
) -> Self::Output<impl StateFnMut<N, Output = bool>>
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.