pub trait EventListenerFuture {
    type Output;

    // Required method
    fn poll_with_strategy<'a, S: Strategy<'a>>(
        self: Pin<&mut Self>,
        strategy: &mut S,
        context: &mut S::Context,
    ) -> Poll<Self::Output>;

    // Provided method
    fn wait(self) -> Self::Output
       where Self: Sized { ... }
}
Expand description

A future that runs using the [event-listener] crate.

This is similar to the Future trait from libstd, with one notable difference: it takes a strategy that tells it whether to operate in a blocking or non-blocking context. The poll_with_strategy method is the equivalent of the poll method in this regard; it uses the Strategy trait to determine how to poll the future.

From here, there are two additional things one can do with this trait:

  • The wait method, which uses the Blocking strategy to poll the future until it is ready, blocking the current thread until it is.
  • The FutureWrapper type, which implements Future and uses the NonBlocking strategy to poll the future.

Required Associated Types§

source

type Output

The type of value produced on completion.

Required Methods§

source

fn poll_with_strategy<'a, S: Strategy<'a>>( self: Pin<&mut Self>, strategy: &mut S, context: &mut S::Context, ) -> Poll<Self::Output>

Poll the future using the provided strategy.

This function should use the Strategy::poll method to poll the future, and proceed based on the result.

Provided Methods§

source

fn wait(self) -> Self::Output
where Self: Sized,

Wait for the future to complete, blocking the current thread.

This function uses the Blocking strategy to poll the future until it is ready.

The future should only return Pending if Strategy::poll returns error. Otherwise, this function polls the future in a hot loop.

Object Safety§

This trait is not object safe.

Implementors§