pub struct TimerHandle(/* private fields */);
Expand description
Represents a on_interval
handler.
Drop all clones of this handler to stop the timer, or call perm
to drop the handler
without cancelling the timer.
Implementations§
source§impl TimerHandle
impl TimerHandle
sourcepub fn dummy() -> TimerHandle
pub fn dummy() -> TimerHandle
Create a handle to nothing, the handle is always in the stopped state.
Note that Option<TimerHandle>
takes up the same space as TimerHandle
and avoids an allocation.
sourcepub fn perm(self)
pub fn perm(self)
Drops the handle but does not drop the handler closure.
The handler closure will be dropped when the app exits or if it is stopped from the inside or using another handle.
sourcepub fn is_permanent(&self) -> bool
pub fn is_permanent(&self) -> bool
If perm
was called in another handle.
If true
the closure will keep being called until the app exits or the timer is stopped from the inside or using
another handle.
sourcepub fn stop(self)
pub fn stop(self)
Drops the handle and forces the handler to drop.
The handler will no longer be called and will drop in the next app update.
sourcepub fn is_stopped(&self) -> bool
pub fn is_stopped(&self) -> bool
If the timer was stopped. The timer can be stopped from the inside, from another handle calling stop
or from the app shutting down.
sourcepub fn interval(&self) -> Duration
pub fn interval(&self) -> Duration
The timer interval. Enabled handlers are called every time this interval elapses.
sourcepub fn set_interval(&self, new_interval: Duration)
pub fn set_interval(&self, new_interval: Duration)
Sets the interval
.
Note that this method does not awake the app, so if this is called from outside the app thread it will only apply on the next app update.
sourcepub fn timestamp(&self) -> DInstant
pub fn timestamp(&self) -> DInstant
Last elapsed time, or the start time if the timer has not elapsed yet.
sourcepub fn pause(&self)
pub fn pause(&self)
Disable the timer, this causes the timer to stop ticking until play
is called.
sourcepub fn is_playing(&self) -> bool
pub fn is_playing(&self) -> bool
If the timer is ticking.
sourcepub fn play(&self, reset: bool)
pub fn play(&self, reset: bool)
Enable the timer, this causes it to start ticking again.
If reset
is true
the last timestamp
is set to now.
Note that this method does not wake the app, so if this is called from outside the app the timer will only start ticking in next app update.
sourcepub fn downgrade(&self) -> WeakTimerHandle
pub fn downgrade(&self) -> WeakTimerHandle
Create a weak handle to the timer.
Trait Implementations§
source§impl Clone for TimerHandle
impl Clone for TimerHandle
source§fn clone(&self) -> TimerHandle
fn clone(&self) -> TimerHandle
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TimerHandle
impl Debug for TimerHandle
source§impl Hash for TimerHandle
impl Hash for TimerHandle
source§impl PartialEq for TimerHandle
impl PartialEq for TimerHandle
impl Eq for TimerHandle
impl StructuralPartialEq for TimerHandle
Auto Trait Implementations§
impl Freeze for TimerHandle
impl !RefUnwindSafe for TimerHandle
impl Send for TimerHandle
impl Sync for TimerHandle
impl Unpin for TimerHandle
impl !UnwindSafe for TimerHandle
Blanket Implementations§
source§impl<T> AnyVarValue for Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
LocalVar<Self>
.source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self
equals other
.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
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more