pub struct Timer { /* private fields */ }
Expand description
A timer, used to schedule execution of callbacks in a given future.
If the callback does not provide the new time period, the next execution will be scheduled for a distant future.
Implementations§
Source§impl Timer
impl Timer
Sourcepub fn new(
callback: impl Fn() -> Option<NaiveDateTime> + Send + 'static,
) -> Self
pub fn new( callback: impl Fn() -> Option<NaiveDateTime> + Send + 'static, ) -> Self
Creates a Timer instance.
pub fn with_graceful_shutdown<O>( self, shutdown: impl Future<Output = O> + Send + 'static, ) -> Self
Sourcepub async fn schedule(&self, deadline: NaiveDateTime) -> Result<(), TimerError>
pub async fn schedule(&self, deadline: NaiveDateTime) -> Result<(), TimerError>
Schedule for execution after a delay.
Trait Implementations§
Source§impl IntoFuture for Timer
impl IntoFuture for Timer
Source§type IntoFuture = Pin<Box<dyn Future<Output = <Timer as IntoFuture>::Output> + Send>>
type IntoFuture = Pin<Box<dyn Future<Output = <Timer as IntoFuture>::Output> + Send>>
Which kind of future are we turning this into?
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Creates a future from a value. Read more
Auto Trait Implementations§
impl Freeze for Timer
impl !RefUnwindSafe for Timer
impl Send for Timer
impl !Sync for Timer
impl Unpin for Timer
impl !UnwindSafe for Timer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more