pub struct Handle { /* private fields */ }
Expand description
Handle to timer instance.
The Handle
allows creating Delay
instances that are driven by the
associated timer.
A Handle
is obtained by calling Timer::handle
, Handle::current
, or
Handle::default
.
-
Timer::handle
: returns a handle associated with the specific timer. The handle will always reference the same timer. -
Handle::current
: returns a handle to the timer for the execution context at the time the function is called. This function must be called from a runtime that has an associated timer or it will panic. The handle will always reference the same timer. -
Handle::default
: returns a handle to the timer for the execution context at the time the handle is used. This function is safe to call at any time. The handle may reference different specific timer instances. CallingHandle::default().delay(...)
is always equivalent toDelay::new(...)
.
Implementations§
Source§impl Handle
impl Handle
Sourcepub fn current() -> Handle
pub fn current() -> Handle
Returns a handle to the current timer.
The current timer is the timer that is currently set as default using
with_default
.
This function should only be called from within the context of
with_default
. Calling this function from outside of this context
will return a Handle
that does not reference a timer. Delay
instances created with this handle will error.
See type level documentation for more ways to obtain a Handle
value.
Sourcepub fn delay(&self, deadline: Instant) -> Delay
pub fn delay(&self, deadline: Instant) -> Delay
Create a Delay
driven by this handle’s associated Timer
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Handle
impl !RefUnwindSafe for Handle
impl Send for Handle
impl Sync for Handle
impl Unpin for Handle
impl !UnwindSafe for Handle
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)