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 T
impl<T> AnyVarValue for T
Source§fn clone_boxed(&self) -> BoxAnyVarValue
fn clone_boxed(&self) -> BoxAnyVarValue
Source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self and other are equal.Source§fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
other if both are of the same type.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,
§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
§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