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
§type IntoFuture = Pin<Box<dyn Future<Output = <Timer as IntoFuture>::Output> + Send, Global>>
type IntoFuture = Pin<Box<dyn Future<Output = <Timer as IntoFuture>::Output> + Send, Global>>
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 !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