Embassy
embassy-time

Crates

git

Versions

default

Flavors

Trait embassy_time::WithTimeout

source ·
pub trait WithTimeout {
    type Output;

    // Required methods
    async fn with_timeout(
        self,
        timeout: Duration,
    ) -> Result<Self::Output, TimeoutError>;
    async fn with_deadline(
        self,
        at: Instant,
    ) -> Result<Self::Output, TimeoutError>;
}
Expand description

Provides functions to run a given future with a timeout or a deadline.

Required Associated Types§

source

type Output

Output type of the future.

Required Methods§

source

async fn with_timeout( self, timeout: Duration, ) -> Result<Self::Output, TimeoutError>

Runs a given future with a timeout.

If the future completes before the timeout, its output is returned. Otherwise, on timeout, work on the future is stopped (poll is no longer called), the future is dropped and Err(TimeoutError) is returned.

source

async fn with_deadline(self, at: Instant) -> Result<Self::Output, TimeoutError>

Runs a given future with a deadline time.

If the future completes before the deadline, its output is returned. Otherwise, on timeout, work on the future is stopped (poll is no longer called), the future is dropped and Err(TimeoutError) is returned.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<F: Future> WithTimeout for F

§

type Output = <F as Future>::Output