macro_rules! define_time_provider {
($provider_instance:expr) => { ... };
}Available on non-crate feature
std, or crate feature std and target_family=wasm and target_os=unknown only.Expand description
Macro to define a custom time provider for no_std platforms.
This macro must be called in your binary crate when using this library on no_std or WASM unknown targets. Pass a static instance of your time provider.
§Example
use core::time::Duration;
use universal_time::{define_time_provider, Instant, MonotonicClock, SystemTime, WallClock};
struct MyTimeProvider;
impl WallClock for MyTimeProvider {
fn system_time(&self) -> SystemTime {
SystemTime::from_unix_duration(Duration::from_secs(0))
}
}
impl MonotonicClock for MyTimeProvider {
fn instant(&self) -> Instant {
Instant::from_ticks(Duration::from_secs(0))
}
}
define_time_provider!(MyTimeProvider);