Skip to main content

DtactInterval

Struct DtactInterval 

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

A repeating timer. tick() is a plain async method mirroring tokio::time::Interval::tick.

Implementations§

Source§

impl DtactInterval

Source

pub fn new(period: Duration) -> Self

Build an interval firing every period, starting one period from now, with the default MissedTickBehavior::Burst catch-up policy (change it via Self::set_missed_tick_behavior).

§Panics

Panics if period is zero — a zero-length period has no sensible tick rate and almost always indicates a caller bug (e.g. an unintended default Duration::ZERO).

Source

pub const fn missed_tick_behavior(&self) -> MissedTickBehavior

The current missed-tick catch-up policy.

Source

pub const fn set_missed_tick_behavior(&mut self, behavior: MissedTickBehavior)

Change the missed-tick catch-up policy. Takes effect starting from the next Self::tick call — doesn’t retroactively change how the interval caught up (or didn’t) from any prior lateness.

Source

pub async fn tick(&mut self) -> Instant

Wait for the next tick, returning the Instant it fired at.

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<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.