Trait StreamExt

Source
pub trait StreamExt: Stream {
    // Provided method
    fn throttle<T>(
        self,
        throttler: T,
        poll_next_max_ready_count: NonZeroUsize,
    ) -> Throttle<Self, T>
       where Self: Stream + Sized,
             T: Throttler<Self::Item> { ... }
}
Expand description

Extension trait for Stream

Provided Methods§

Source

fn throttle<T>( self, throttler: T, poll_next_max_ready_count: NonZeroUsize, ) -> Throttle<Self, T>
where Self: Stream + Sized, T: Throttler<Self::Item>,

Throttle an input stream

The throttler defines the throttling strategy.

The poll_next_max_ready_count argument controls how many Ready items are polled at once from the input stream during an invocation of Stream::poll_next() before polling the throttler. This limit ensures that input streams which are always ready are not polled forever. A value of NonZeroUsize::MIN will poll the input stream only once and could be used as a save default. Using a greater value to skip multiple items at once will reduce the number of calls to the throttler and improves the performance and efficiency.

Implementors§

Source§

impl<S: Stream> StreamExt for S