Trait DelayMs

Source
pub trait DelayMs {
    type Delay;
    type Error;

    // Required methods
    fn start(&mut self, ms: Self::Delay) -> Result<(), Self::Error>;
    fn poll_delay_ms(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
    ) -> Poll<Result<(), Self::Error>>;
    fn cancel(&mut self) -> Result<(), Self::Error>;

    // Provided methods
    fn poll_delay_ms_unpin(
        &mut self,
        cx: &mut Context<'_>,
    ) -> Poll<Result<(), Self::Error>>
       where Self: Unpin { ... }
    fn delay_ms(&mut self, ms: Self::Delay) -> DelayMsFuture<'_, Self> 
       where Self: Unpin { ... }
}
Available on crate feature delay only.

Required Associated Types§

Source

type Delay

The type of duration to delay for.

Source

type Error

The error returned on failure.

Required Methods§

Source

fn start(&mut self, ms: Self::Delay) -> Result<(), Self::Error>

Start a new delay.

Source

fn poll_delay_ms( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>

Poll a delay of ms milliseconds. This function may wake the calling function rather than the waker.

Source

fn cancel(&mut self) -> Result<(), Self::Error>

Attempt to cancel a delay in progress.

Provided Methods§

Source

fn poll_delay_ms_unpin( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>
where Self: Unpin,

Source

fn delay_ms(&mut self, ms: Self::Delay) -> DelayMsFuture<'_, Self>
where Self: Unpin,

Delay for ms milliseconds. Starts a new delay and returns a Future that completes when either the timer expires. The returned future also implements Stream if this delay is Periodic.

When dropped, this future will attempt to cancel the current delay.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§