pub trait StreamExt: Stream {
    fn buffer_unordered_weighted<Fut>(
        self,
        max_weight: usize
    ) -> BufferUnorderedWeighted<Self>
    where
        Self: Sized + Stream<Item = (usize, Fut)>,
        Fut: Future
, { ... } }
Expand description

An extension trait for Streams that provides buffer_unordered_weighted.

Provided Methods

An adaptor for creating a buffered list of pending futures (unordered), where each future has a different weight.

This stream must return values of type (usize, impl Future), where the usize indicates the weight of each future. This adaptor will buffer futures up to weight max_weight, and then return the outputs in the order in which they complete.

The weight may be exceeded if the last future to be queued has a weight greater than max_weight minus the total weight of currently executing futures. However, no further futures will be queued until the total weights of running futures falls below max_weight.

The adaptor will buffer futures in the order they’re returned by the stream, without doing any reordering based on weight.

The weight of a future can be 0, in which case it will not count towards the total weight.

The returned stream will be a stream of each future’s output.

Examples

See the crate documentation for an example.

Implementors