pub trait SampleExt<T, R>: Stream<Item = StreamItem<T>> + Sizedwhere
T: Fluxion,
T::Inner: Clone + Debug + Ord + Unpin + Send + Sync + 'static,
T::Timestamp: Debug + Ord + Copy + 'static,
R: Runtime,{
// Required method
fn sample(
self,
duration: Duration,
) -> impl Stream<Item = StreamItem<T>> + Send + Sync;
}Expand description
Extension trait providing the sample operator for streams.
This trait allows any stream of StreamItem<T> where T: Fluxion to sample emissions
at periodic intervals.
Required Methods§
Sourcefn sample(
self,
duration: Duration,
) -> impl Stream<Item = StreamItem<T>> + Send + Sync
fn sample( self, duration: Duration, ) -> impl Stream<Item = StreamItem<T>> + Send + Sync
Samples the stream at periodic intervals.
The sample operator emits the most recently emitted value from the source stream within periodic time intervals.
- If the source emits multiple values within the interval, only the last one is emitted.
- If the source emits no values within the interval, nothing is emitted for that interval.
- Errors are passed through immediately.
§Arguments
duration- The sampling interval
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.