Struct FuturesUnordered

struct FuturesUnordered<Fut> { ... }

A set of futures which may complete in any order.

See FuturesOrdered for a version of this type that preserves a FIFO 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.

Implementations

impl<Fut> FuturesUnordered<Fut>

fn clear(self: &mut Self)

Clears the set, removing all futures.

impl<Fut> FuturesUnordered<Fut>

fn new() -> Self

Constructs a new, empty FuturesUnordered.

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

fn len(self: &Self) -> usize

Returns the number of futures contained in the set.

This represents the total number of in-flight futures.

fn is_empty(self: &Self) -> bool

Returns true if the set contains no futures.

fn push(self: &Self, future: Fut)

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.

fn iter(self: &Self) -> Iter<'_, Fut>
where
    Fut: Unpin

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

fn iter_pin_ref(self: Pin<&Self>) -> IterPinRef<'_, Fut>

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

fn iter_mut(self: &mut Self) -> IterMut<'_, Fut>
where
    Fut: Unpin

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

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

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

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

fn spawn_local_obj(self: &Self, future_obj: LocalFutureObj<'static, ()>) -> Result<(), SpawnError>

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

fn spawn_obj(self: &Self, future_obj: FutureObj<'static, ()>) -> Result<(), SpawnError>

impl<Fut> Debug for FuturesUnordered<Fut>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl<Fut> Default for FuturesUnordered<Fut>

fn default() -> Self

impl<Fut> Drop for FuturesUnordered<Fut>

fn drop(self: &mut Self)

impl<Fut> Extend for FuturesUnordered<Fut>

fn extend<I>(self: &mut Self, iter: I)
where
    I: IntoIterator<Item = Fut>

impl<Fut> Freeze for FuturesUnordered<Fut>

impl<Fut> FromIterator for FuturesUnordered<Fut>

fn from_iter<I>(iter: I) -> Self
where
    I: IntoIterator<Item = Fut>

impl<Fut> RefUnwindSafe for FuturesUnordered<Fut>

impl<Fut> Unpin for FuturesUnordered<Fut>

impl<Fut> UnsafeUnpin for FuturesUnordered<Fut>

impl<Fut> UnwindSafe for FuturesUnordered<Fut>

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

fn is_terminated(self: &Self) -> bool

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

fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<<Self as >::Item>>
fn size_hint(self: &Self) -> (usize, Option<usize>)

impl<Fut: Send + Sync> Sync for FuturesUnordered<Fut>

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

impl<Fut: Unpin> IntoIterator for FuturesUnordered<Fut>

fn into_iter(self: Self) -> <Self as >::IntoIter

impl<S> TryStreamExt for FuturesUnordered<Fut>

impl<S, T, E> TryStream for FuturesUnordered<Fut>

fn try_poll_next(self: Pin<&mut S>, cx: &mut Context<'_>) -> Poll<Option<Result<<S as TryStream>::Ok, <S as TryStream>::Error>>>

impl<Sp> LocalSpawnExt for FuturesUnordered<Fut>

impl<Sp> SpawnExt for FuturesUnordered<Fut>

impl<T> Any for FuturesUnordered<Fut>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for FuturesUnordered<Fut>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for FuturesUnordered<Fut>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for FuturesUnordered<Fut>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> StreamExt for FuturesUnordered<Fut>

impl<T, U> Into for FuturesUnordered<Fut>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for FuturesUnordered<Fut>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for FuturesUnordered<Fut>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>