cranpose_core/platform.rs
1//! Platform abstraction traits for Compose runtime services.
2//!
3//! These traits allow Compose to delegate scheduling and clock
4//! responsibilities to the host platform, enabling integration with
5//! different environments without depending directly on `std` APIs.
6
7/// Schedules work for the Compose runtime.
8///
9/// Implementations are responsible for triggering frame processing and
10/// executing background tasks on behalf of Compose. They must be safe to
11/// use from multiple threads.
12pub trait RuntimeScheduler: Send + Sync {
13 /// Request that the host schedule a new frame.
14 fn schedule_frame(&self);
15}
16
17/// Provides timing information for the runtime.
18pub trait Clock: Send + Sync {
19 /// Instant type produced by this clock implementation.
20 type Instant: Copy + Send + Sync;
21
22 /// Returns the current instant.
23 fn now(&self) -> Self::Instant;
24
25 /// Returns the number of milliseconds elapsed since `since`.
26 fn elapsed_millis(&self, since: Self::Instant) -> u64;
27}