Skip to main content

Module rt

Module rt 

Source
Expand description

Timers and clocks that work the same on a host and in a browser: tokio’s timer and std::time on a host, the browser’s setTimeout and performance.now() under wasm32-unknown-unknown, where std::time::Instant::now and tokio’s timer driver are unavailable.

Structs§

Aborted
The task was aborted before it finished.
Elapsed
A deadline passed before the future finished.
Instant
A monotonic instant: tokio’s on a host, so a paused test clock moves it; performance.now() in a browser. A measurement of a monotonically nondecreasing clock. Opaque and useful only with Duration.
SystemTime
A measurement of the system clock, useful for talking to external entities like the file system or other processes.
Task
A background task that can be awaited or aborted, on either target. Dropping it detaches the task, which runs on, as tokio’s JoinHandle does.

Constants§

UNIX_EPOCH
An anchor in time which can be used to create new SystemTime instances or learn about where in time a SystemTime lies.

Traits§

MaybeSend
Send on a host; nothing in a browser, where values that touch JavaScript stay on the thread that made them. Bound a future or stream by it where a host needs Send and a browser cannot give it.

Functions§

sleep
Wait for duration.
spawn
Run future in the background: on tokio’s runtime on a host, on the browser’s event loop in a browser.
spawn_task
Run future in the background, as spawn does, keeping a handle to await or abort it.
timeout
future’s output, unless duration passes first.