Struct async_timer::Timed[][src]

pub struct Timed<'a, F, T = PlatformTimer> { /* fields omitted */ }
Expand description

Limiter on time to wait for underlying Future

Usage

async fn job() {
}

async fn do_job() {
    let mut job = job();
    let job = unsafe {
        core::pin::Pin::new_unchecked(&mut job)
    };
    let work = unsafe {
        async_timer::Timed::platform_new(job, core::time::Duration::from_secs(1))
    };

    match work.await {
        Ok(_) => println!("I'm done!"),
        //You can retry by polling `expired`
        Err(expired) => println!("Job expired: {}", expired),
    }
}

Implementations

Creates new instance using Timer alias.

Creates new instance with specified timeout

Unsafe version of new that doesn’t require Unpin.

Requires to specify Timer type (e.g. Timed::<timer::Platform>::new())

Trait Implementations

The type of value produced on completion.

Attempt to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

🔬 This is a nightly-only experimental API. (into_future)

The output that the future will produce on completion.

🔬 This is a nightly-only experimental API. (into_future)

Which kind of future are we turning this into?

🔬 This is a nightly-only experimental API. (into_future)

Creates a future from a value.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.