Skip to main content

Clock

Trait Clock 

Source
pub trait Clock {
    // Required methods
    fn now_ms(&self) -> u64;
    fn schedule(&self, after_ms: u64, f: Box<dyn FnOnce()>);

    // Provided method
    fn frame(&self, f: Box<dyn FnOnce()>) { ... }
}
Expand description

The clock the cache keeps time by, and its timers (UI-10: a live’s debounce_ms).

Required Methods§

Source

fn now_ms(&self) -> u64

Source

fn schedule(&self, after_ms: u64, f: Box<dyn FnOnce()>)

Runs f once, after_ms from now.

Provided Methods§

Source

fn frame(&self, f: Box<dyn FnOnce()>)

STUDIO-16: runs f once at the next animation frame — the changes heard until then published together. A clock with no frames (the tests’ ManualClock unless ManualClock::with_frames) runs it now.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§