Allow to disable clocks in WasiCtx (#6007)
Takes the approach described in #6004, but also creates a wrapper for the monotonic time that encapsulates the `creation_time` field as well, since they logically belong and are always used together. This makes it easier to configure `WasiCtx` with custom clocks as well as disable them for security or determinism reasons. Closes #6004.
This commit is contained in:
@@ -35,13 +35,7 @@ impl WasiMonotonicClock for MonotonicClock {
|
||||
}
|
||||
|
||||
pub fn clocks_ctx() -> WasiClocks {
|
||||
let system = Box::new(SystemClock::new(ambient_authority()));
|
||||
let monotonic = cap_std::time::MonotonicClock::new(ambient_authority());
|
||||
let creation_time = monotonic.now();
|
||||
let monotonic = Box::new(MonotonicClock(monotonic));
|
||||
WasiClocks {
|
||||
system,
|
||||
monotonic,
|
||||
creation_time,
|
||||
}
|
||||
WasiClocks::new()
|
||||
.with_system(SystemClock::new(ambient_authority()))
|
||||
.with_monotonic(MonotonicClock::new(ambient_authority()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user