6464//! ```
6565
6666use crate :: cli:: WasiCliView ;
67+ use crate :: clocks:: WasiClocksView ;
6768use crate :: p2:: bindings:: {
6869 cli:: {
6970 stderr:: Host as _, stdin:: Host as _, stdout:: Host as _, terminal_input, terminal_output,
@@ -1232,15 +1233,13 @@ impl wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiP1Ctx {
12321233 id : types:: Clockid ,
12331234 ) -> Result < types:: Timestamp , types:: Error > {
12341235 let res = match id {
1235- types:: Clockid :: Realtime => wall_clock:: Host :: resolution ( & mut self . as_wasi_impl ( ) )
1236+ types:: Clockid :: Realtime => wall_clock:: Host :: resolution ( & mut self . clocks ( ) )
12361237 . context ( "failed to call `wall_clock::resolution`" )
12371238 . map_err ( types:: Error :: trap) ?
12381239 . try_into ( ) ?,
1239- types:: Clockid :: Monotonic => {
1240- monotonic_clock:: Host :: resolution ( & mut self . as_wasi_impl ( ) )
1241- . context ( "failed to call `monotonic_clock::resolution`" )
1242- . map_err ( types:: Error :: trap) ?
1243- }
1240+ types:: Clockid :: Monotonic => monotonic_clock:: Host :: resolution ( & mut self . clocks ( ) )
1241+ . context ( "failed to call `monotonic_clock::resolution`" )
1242+ . map_err ( types:: Error :: trap) ?,
12441243 types:: Clockid :: ProcessCputimeId | types:: Clockid :: ThreadCputimeId => {
12451244 return Err ( types:: Errno :: Badf . into ( ) ) ;
12461245 }
@@ -1256,11 +1255,11 @@ impl wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiP1Ctx {
12561255 _precision : types:: Timestamp ,
12571256 ) -> Result < types:: Timestamp , types:: Error > {
12581257 let now = match id {
1259- types:: Clockid :: Realtime => wall_clock:: Host :: now ( & mut self . as_wasi_impl ( ) )
1258+ types:: Clockid :: Realtime => wall_clock:: Host :: now ( & mut self . clocks ( ) )
12601259 . context ( "failed to call `wall_clock::now`" )
12611260 . map_err ( types:: Error :: trap) ?
12621261 . try_into ( ) ?,
1263- types:: Clockid :: Monotonic => monotonic_clock:: Host :: now ( & mut self . as_wasi_impl ( ) )
1262+ types:: Clockid :: Monotonic => monotonic_clock:: Host :: now ( & mut self . clocks ( ) )
12641263 . context ( "failed to call `monotonic_clock::now`" )
12651264 . map_err ( types:: Error :: trap) ?,
12661265 types:: Clockid :: ProcessCputimeId | types:: Clockid :: ThreadCputimeId => {
@@ -2320,7 +2319,7 @@ impl wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiP1Ctx {
23202319 types:: Clockid :: Monotonic => ( timeout, absolute) ,
23212320 types:: Clockid :: Realtime if !absolute => ( timeout, false ) ,
23222321 types:: Clockid :: Realtime => {
2323- let now = wall_clock:: Host :: now ( & mut self . as_wasi_impl ( ) )
2322+ let now = wall_clock:: Host :: now ( & mut self . clocks ( ) )
23242323 . context ( "failed to call `wall_clock::now`" )
23252324 . map_err ( types:: Error :: trap) ?;
23262325
@@ -2343,11 +2342,11 @@ impl wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiP1Ctx {
23432342 _ => return Err ( types:: Errno :: Inval . into ( ) ) ,
23442343 } ;
23452344 if absolute {
2346- monotonic_clock:: Host :: subscribe_instant ( & mut self . as_wasi_impl ( ) , timeout)
2345+ monotonic_clock:: Host :: subscribe_instant ( & mut self . clocks ( ) , timeout)
23472346 . context ( "failed to call `monotonic_clock::subscribe_instant`" )
23482347 . map_err ( types:: Error :: trap) ?
23492348 } else {
2350- monotonic_clock:: Host :: subscribe_duration ( & mut self . as_wasi_impl ( ) , timeout)
2349+ monotonic_clock:: Host :: subscribe_duration ( & mut self . clocks ( ) , timeout)
23512350 . context ( "failed to call `monotonic_clock::subscribe_duration`" )
23522351 . map_err ( types:: Error :: trap) ?
23532352 }
0 commit comments