pub trait TimeProvider {
// Required methods
fn current_time_ms(&self) -> Milliseconds;
fn current_time_us(&self) -> Microseconds;
fn last_time_ms(&self) -> Milliseconds;
fn last_time_us(&self) -> Microseconds;
fn update_last_time_ms(&mut self, time: Milliseconds);
fn update_last_time_us(&mut self, time: Microseconds);
// Provided methods
fn elapsed_ms(&mut self) -> Milliseconds { ... }
fn elapsed_us(&mut self) -> Microseconds { ... }
fn reset(&mut self) { ... }
}Expand description
Trait for providing time information to the animation system.
This trait abstracts time operations to support both std and no_std environments. Implementations can use system clocks, hardware timers, or external time sources.
Required Methods§
Sourcefn current_time_ms(&self) -> Milliseconds
fn current_time_ms(&self) -> Milliseconds
Get the current time in milliseconds since some reference point.
The reference point doesn’t matter as long as it’s consistent. This is typically used for calculating elapsed time between calls.
Sourcefn current_time_us(&self) -> Microseconds
fn current_time_us(&self) -> Microseconds
Get the current time in microseconds since some reference point.
This provides higher precision timing for fine-grained animations.
The reference point should be the same as current_time_ms().
Sourcefn last_time_ms(&self) -> Milliseconds
fn last_time_ms(&self) -> Milliseconds
Get the last recorded time in milliseconds.
This is used internally by elapsed_ms().
Sourcefn last_time_us(&self) -> Microseconds
fn last_time_us(&self) -> Microseconds
Get the last recorded time in microseconds.
This is used internally by elapsed_us().
Sourcefn update_last_time_ms(&mut self, time: Milliseconds)
fn update_last_time_ms(&mut self, time: Milliseconds)
Update the last recorded time in milliseconds.
This is used internally by elapsed_ms().
Sourcefn update_last_time_us(&mut self, time: Microseconds)
fn update_last_time_us(&mut self, time: Microseconds)
Update the last recorded time in microseconds.
This is used internally by elapsed_us().
Provided Methods§
Sourcefn elapsed_ms(&mut self) -> Milliseconds
fn elapsed_ms(&mut self) -> Milliseconds
Calculate elapsed time in milliseconds since the last call.
This is a convenience method that handles the delta calculation. The implementation should track the last time internally.
Sourcefn elapsed_us(&mut self) -> Microseconds
fn elapsed_us(&mut self) -> Microseconds
Calculate elapsed time in microseconds since the last call.
This is a convenience method that handles the delta calculation. The implementation should track the last time internally.
Implementors§
impl TimeProvider for ManualTimeProvider
impl TimeProvider for StdTimeProvider
std only.