Struct futures::stream::futures_unordered::FuturesUnordered[][src]

#[must_use = "streams do nothing unless polled"]pub struct FuturesUnordered<Fut> { /* fields omitted */ }

A set of futures which may complete in any order.

This structure is optimized to manage a large number of futures. Futures managed by FuturesUnordered will only be polled when they generate wake-up notifications. This reduces the required amount of work needed to poll large numbers of futures.

FuturesUnordered can be filled by collecting an iterator of futures into a FuturesUnordered, or by pushing futures onto an existing FuturesUnordered. When new futures are added, poll_next must be called in order to begin receiving wake-ups for new futures.

Note that you can create a ready-made FuturesUnordered via the collect method, or you can start with an empty set with the FuturesUnordered::new constructor.

This type is only available when the std or alloc feature of this library is activated, and it is activated by default.


impl<Fut> FuturesUnordered<Fut>[src]

pub fn new() -> FuturesUnordered<Fut>[src]

Constructs a new, empty FuturesUnordered.

The returned FuturesUnordered does not contain any futures. In this state, FuturesUnordered::poll_next will return Poll::Ready(None).

pub fn len(&self) -> usize[src]

Returns the number of futures contained in the set.

This represents the total number of in-flight futures.

pub fn is_empty(&self) -> bool[src]

Returns true if the set contains no futures.

pub fn push(&self, future: Fut)[src]

Push a future into the set.

This method adds the given future to the set. This method will not call poll on the submitted future. The caller must ensure that FuturesUnordered::poll_next is called in order to receive wake-up notifications for the given future.

pub fn iter(&self) -> Iter<'_, Fut>

Notable traits for Iter<'a, Fut>

impl<'a, Fut> Iterator for Iter<'a, Fut> where
    Fut: Unpin
type Item = &'a Fut;
    Fut: Unpin

Returns an iterator that allows inspecting each future in the set.

pub fn iter_mut(&mut self) -> IterMut<'_, Fut>

Notable traits for IterMut<'a, Fut>

impl<'a, Fut> Iterator for IterMut<'a, Fut> where
    Fut: Unpin
type Item = &'a mut Fut;
    Fut: Unpin

Returns an iterator that allows modifying each future in the set.

pub fn iter_pin_mut(
    self: Pin<&mut FuturesUnordered<Fut>>
) -> IterPinMut<'_, Fut>

Notable traits for IterPinMut<'a, Fut>

impl<'a, Fut> Iterator for IterPinMut<'a, Fut> type Item = Pin<&'a mut Fut>;

Returns an iterator that allows modifying each future in the set.

Trait Implementations

impl<Fut> Debug for FuturesUnordered<Fut>[src]

impl<Fut> Default for FuturesUnordered<Fut>[src]

impl<Fut> Drop for FuturesUnordered<Fut>[src]

impl<Fut> Extend<Fut> for FuturesUnordered<Fut>[src]

impl<Fut> FromIterator<Fut> for FuturesUnordered<Fut>[src]

impl<Fut> FusedStream for FuturesUnordered<Fut> where
    Fut: Future

impl<'_> LocalSpawn for FuturesUnordered<LocalFutureObj<'_, ()>>[src]

impl<Fut> Send for FuturesUnordered<Fut> where
    Fut: Send

impl<'_> Spawn for FuturesUnordered<FutureObj<'_, ()>>[src]

impl<Fut> Stream for FuturesUnordered<Fut> where
    Fut: Future

type Item = <Fut as Future>::Output

Values yielded by the stream.

impl<Fut> Sync for FuturesUnordered<Fut> where
    Fut: Sync

impl<Fut> Unpin for FuturesUnordered<Fut>[src]

Auto Trait Implementations

impl<Fut> !RefUnwindSafe for FuturesUnordered<Fut>

impl<Fut> !UnwindSafe for FuturesUnordered<Fut>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<Sp> LocalSpawnExt for Sp where
    Sp: LocalSpawn + ?Sized

impl<Sp> SpawnExt for Sp where
    Sp: Spawn + ?Sized

impl<T> StreamExt for T where
    T: Stream + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<S, T, E> TryStream for S where
    S: Stream<Item = Result<T, E>> + ?Sized

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

impl<S> TryStreamExt for S where
    S: TryStream + ?Sized