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>

source

pub fn new(timeout: Duration, capacity: usize) -> Self

source§

impl<ID, O> FuturesMap<ID, O>where ID: Clone + Hash + Eq + Send + Unpin + 'static, O: 'static,

source

pub fn try_push<F>( &mut self, future_id: ID, future: F ) -> Result<(), PushError<BoxFuture<'_, O>>>where F: Future<Output = O> + Send + 'static,

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.

source

pub fn remove(&mut self, id: ID) -> Option<BoxFuture<'static, O>>

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn poll_ready_unpin(&mut self, cx: &mut Context<'_>) -> Poll<()>

source

pub fn poll_unpin( &mut self, cx: &mut Context<'_> ) -> Poll<(ID, Result<O, Timeout>)>

Auto Trait Implementations§

§

impl<ID, O> !RefUnwindSafe for FuturesMap<ID, O>

§

impl<ID, O> Send for FuturesMap<ID, O>where ID: Send,

§

impl<ID, O> !Sync for FuturesMap<ID, O>

§

impl<ID, O> Unpin for FuturesMap<ID, O>

§

impl<ID, O> !UnwindSafe for FuturesMap<ID, O>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

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

source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.