Skip to main content

proxima_core/time/drivers/
unbound.rs

1//! Always-available fallback driver. Selected when no `time-driver-*`
2//! feature is active *and* no `PROXIMA_PROFILE` is set — most often during
3//! alloc-only cross-compile verification of downstream crates (the
4//! consumer wants to prove its source compiles for a no_std target;
5//! it doesn't actually exercise the time primitives at runtime).
6//!
7//! Any call to [`now`](crate::time::Driver::now) or
8//! [`schedule_wake`](crate::time::Driver::schedule_wake) panics with a message
9//! pointing at the missing driver configuration. This is intentional:
10//! shipping a build that links the unbound driver and *does* use timer
11//! primitives is a configuration error, and silent zero-time / silent
12//! never-fires would mask it.
13
14use core::task::Waker;
15
16use crate::time::{Driver, Instant};
17
18/// Singleton — referenced by the build.rs fallback when no other
19/// driver is selectable.
20pub static DRIVER: UnboundDriver = UnboundDriver;
21
22/// Zero-sized panics-on-use driver.
23pub struct UnboundDriver;
24
25impl Driver for UnboundDriver {
26    fn now(&self) -> Instant {
27        panic!(
28            "proxima_core::time has no driver bound; activate a `time-driver-*` \
29             feature (e.g. time-driver-std-thread, time-driver-mock) or set \
30             PROXIMA_PROFILE"
31        );
32    }
33
34    fn schedule_wake(&self, _deadline: Instant, _waker: Waker) {
35        panic!(
36            "proxima_core::time has no driver bound; activate a `time-driver-*` \
37             feature (e.g. time-driver-std-thread, time-driver-mock) or set \
38             PROXIMA_PROFILE"
39        );
40    }
41}