Skip to main content

Deadline

Struct Deadline 

Source
pub struct Deadline { /* private fields */ }
Expand description

Future returned by deadline.

§Examples

Wait 100ms and print “100 ms have elapsed”.

use ntex::time::{deadline, Millis};

#[ntex::main]
async fn main() {
    deadline(Millis(100)).await;
    println!("100 ms have elapsed");
}

Implementations§

Source§

impl Deadline

Source

pub fn new(duration: Millis) -> Deadline ⓘ

Creates a new deadline future.

A zero duration creates a deadline that never completes.

Source

pub async fn wait(&self)

Waits until this deadline has elapsed.

Source

pub fn reset<T>(&mut self, millis: T)
where T: Into<Millis>,

Resets the Deadline instance to a new deadline.

Calling this function allows changing the instant at which the Deadline future completes without having to create new associated state.

This function can be called both before and after the future has completed.

Source

pub fn is_elapsed(&self) -> bool

Returns true if Deadline has elapsed.

A disabled zero-duration deadline is reported as elapsed here even though polling it remains pending. Use this method to determine whether there is an active future deadline to wait for.

Source

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

Polls until this deadline has elapsed.

A zero-duration deadline remains pending until it is reset.

Trait Implementations§

Source§

impl Debug for Deadline

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Future for Deadline

Source§

type Output = ()

The type of value produced on completion.
Source§

fn poll( self: Pin<&mut Deadline>, cx: &mut Context<'_>, ) -> Poll<<Deadline as Future>::Output>

Attempts 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§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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<F> IntoFuture for F
where F: Future,

Source§

type Output = <F as Future>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = F

Which kind of future are we turning this into?
Source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. Read more
Source§

impl<F> OnDropFutureExt for F
where F: Future,

Source§

fn on_drop<F>(self, on_drop: F) -> OnDropFuture<Self, F> ⓘ
where F: FnOnce(),

Wraps this future so that on_drop is called if the future is dropped before it completes. The callback is cancelled once the future completes, whatever its output.
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.