pub struct FuturesMap<ID, O> { /* private fields */ }Expand description
Represents a map of Futures.
Each future must finish within the specified time and the map never outgrows its capacity.
Implementations§
Source§impl<ID, O> FuturesMap<ID, O>
impl<ID, O> FuturesMap<ID, O>
Source§impl<ID, O> FuturesMap<ID, O>
impl<ID, O> FuturesMap<ID, O>
Sourcepub fn try_push<F>(
&mut self,
future_id: ID,
future: F,
) -> Result<(), PushError<Pin<Box<dyn AnyFuture<Output = O> + Send>>>>where
F: AnyFuture<Output = O>,
pub fn try_push<F>(
&mut self,
future_id: ID,
future: F,
) -> Result<(), PushError<Pin<Box<dyn AnyFuture<Output = O> + Send>>>>where
F: AnyFuture<Output = O>,
Push a future into the map.
This method inserts the given future with defined future_id to the set.
If the length of the map is equal to the capacity, this method returns PushError::BeyondCapacity,
that contains the passed future. In that case, the future is not inserted to the map.
If a future with the given future_id already exists, then the old future will be replaced by a new one.
In that case, the returned error PushError::Replaced contains the old future.
pub fn remove( &mut self, id: ID, ) -> Option<Pin<Box<dyn AnyFuture<Output = O> + Send>>>
pub fn contains(&self, id: ID) -> bool
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn poll_ready_unpin(&mut self, cx: &mut Context<'_>) -> Poll<()>
pub fn poll_unpin( &mut self, cx: &mut Context<'_>, ) -> Poll<(ID, Result<O, Timeout>)>
Sourcepub fn iter_of_type<T>(&self) -> impl Iterator<Item = (&ID, Pin<&T>)>where
T: 'static,
pub fn iter_of_type<T>(&self) -> impl Iterator<Item = (&ID, Pin<&T>)>where
T: 'static,
Returns an iterator over all futures of type T pushed via FuturesMap::try_push.
This iterator returns futures in an arbitrary order, which may change.
If downcasting a future to T fails it will be skipped in the iterator.
Sourcepub fn iter_mut_of_type<T>(
&mut self,
) -> impl Iterator<Item = (&ID, Pin<&mut T>)>where
T: 'static,
pub fn iter_mut_of_type<T>(
&mut self,
) -> impl Iterator<Item = (&ID, Pin<&mut T>)>where
T: 'static,
Returns an iterator with mutable access over all futures of type T pushed via
FuturesMap::try_push.
This iterator returns futures in an arbitrary order, which may change.
If downcasting a future to T fails it will be skipped in the iterator.