move more deps to cap-std-sync, define own SystemTimeSpec
This commit is contained in:
@@ -1,34 +1,20 @@
|
||||
use cap_std::time::{Duration, Instant, MonotonicClock, SystemClock, SystemTime};
|
||||
use cap_time_ext::{MonotonicClockExt, SystemClockExt};
|
||||
use cap_std::time::{Duration, Instant, SystemTime};
|
||||
|
||||
pub enum SystemTimeSpec {
|
||||
SymbolicNow,
|
||||
Absolute(SystemTime),
|
||||
}
|
||||
|
||||
pub trait WasiSystemClock {
|
||||
fn resolution(&self) -> Duration;
|
||||
fn now(&self, precision: Duration) -> SystemTime;
|
||||
}
|
||||
|
||||
impl WasiSystemClock for SystemClock {
|
||||
fn resolution(&self) -> Duration {
|
||||
SystemClockExt::resolution(self)
|
||||
}
|
||||
fn now(&self, precision: Duration) -> SystemTime {
|
||||
self.now_with(precision)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait WasiMonotonicClock {
|
||||
fn resolution(&self) -> Duration;
|
||||
fn now(&self, precision: Duration) -> Instant;
|
||||
}
|
||||
|
||||
impl WasiMonotonicClock for MonotonicClock {
|
||||
fn resolution(&self) -> Duration {
|
||||
MonotonicClockExt::resolution(self)
|
||||
}
|
||||
fn now(&self, precision: Duration) -> Instant {
|
||||
self.now_with(precision)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WasiClocks {
|
||||
pub system: Box<dyn WasiSystemClock>,
|
||||
pub monotonic: Box<dyn WasiMonotonicClock>,
|
||||
|
||||
Reference in New Issue
Block a user