TimeoutExt

Trait TimeoutExt 

Source
pub trait TimeoutExt<T, R>: Stream<Item = StreamItem<T>> + Sized
where T: Fluxion, T::Inner: Clone + Debug + Ord + Unpin + Send + Sync + 'static, T::Timestamp: Debug + Ord + Copy + 'static, R: Runtime,
{ // Required method fn timeout( self, duration: Duration, ) -> impl Stream<Item = StreamItem<T>> + Send + Sync; }
Expand description

Extension trait providing the timeout operator for streams.

This trait allows any stream of StreamItem<T> where T: Fluxion to enforce a timeout between emissions.

Required Methods§

Source

fn timeout( self, duration: Duration, ) -> impl Stream<Item = StreamItem<T>> + Send + Sync

Errors if the stream does not emit any value within the specified duration.

The timeout operator monitors the time interval between emissions from the source stream. If the source stream does not emit any value within the specified duration, the operator emits a FluxionError::TimeoutError with “Timeout” context and terminates the stream.

  • If the source emits a value, the timer is reset.
  • If the source completes, the timeout operator completes.
  • If the source errors, the error is passed through.
§Arguments
  • duration - The timeout duration

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<S, T> TimeoutExt<T, TokioRuntime> for S
where S: Stream<Item = StreamItem<T>> + Send + Sync, T: Fluxion<Timestamp = <DefaultRuntime as Runtime>::Instant> + Send + Sync, T::Inner: Clone + Debug + Ord + Unpin + Send + Sync + 'static,