#[repr(C)]pub struct Timer {
pub refany: RefAny,
pub node_id: OptionDomNodeId,
pub created: Instant,
pub last_run: OptionInstant,
pub run_count: usize,
pub delay: OptionDuration,
pub interval: OptionDuration,
pub timeout: OptionDuration,
pub callback: TimerCallback,
}Expand description
A Timer is a function that runs on every frame or at intervals.
Fields§
§refany: RefAny§node_id: OptionDomNodeId§created: Instant§last_run: OptionInstant§run_count: usize§delay: OptionDuration§interval: OptionDuration§timeout: OptionDuration§callback: TimerCallbackImplementations§
Source§impl Timer
impl Timer
pub fn create<C: Into<TimerCallback>>( refany: RefAny, callback: C, get_system_time_fn: GetSystemTimeCallback, ) -> Self
pub fn tick_millis(&self) -> u64
pub fn is_about_to_finish(&self, instant_now: &Instant) -> bool
pub fn instant_of_next_run(&self) -> Instant
pub fn with_delay(self, delay: Duration) -> Self
pub fn with_interval(self, interval: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Sourcepub fn invoke(
&mut self,
callback_info: &CallbackInfo,
get_system_time_fn: &GetSystemTimeCallback,
) -> TimerCallbackReturn
pub fn invoke( &mut self, callback_info: &CallbackInfo, get_system_time_fn: &GetSystemTimeCallback, ) -> TimerCallbackReturn
Invoke the timer callback and update internal state
Returns DoNothing + Continue if the timer is not ready to run yet
(delay not elapsed for first run, or interval not elapsed for subsequent runs).
Trait Implementations§
impl Eq for Timer
impl StructuralPartialEq for Timer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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>
Converts
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>
Converts
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