Expand description
§rings-runtime
The runtime contracts shared by every Rings crate that runs on both native Tokio and the browser’s JavaScript event loop.
| Contract | Native | Browser (browser feature on a wasm target) |
|---|---|---|
sleep | futures-timer; never fails | chained setTimeout on the window, worker or service-worker scope; fails with TimerError |
Spawner / spawn_detached | current Tokio runtime (tokio feature); RuntimeUnavailable outside one | spawn_local; always available |
run_detached | awaited work owned by the runtime | same |
TaskSet | detached tasks counted while live, whose drain can be awaited | same |
run_blocking | blocking work on Tokio’s blocking pool, owned by the runtime; RuntimeUnavailable outside one | absent (no blocking pool) |
MaybeSend / MaybeSendSync | Send / Send + Sync | no bound |
The crate carries no Rings protocol vocabulary; it sits below rings-transport, so every
layer above it adapts to the runtime through one set of laws instead of choosing
futures_timer, setTimeout or a spawn primitive locally. Work whose cancellation the
caller owns is deliberately not served here: it keeps its own abort handle.
Macros§
- maybe_
send - A trait object that is
Sendon native and unconstrained in the browser. - maybe_
send_ sync - A trait object that is
Send + Syncon native and unconstrained in the browser.
Structs§
- Abandoned
- Scheduled work ended without publishing its output: it panicked, or its runtime shut down.
- Drained
- Resolves at an instant no task of its
TaskSetis live. - Joined
- The output of a task of a
TaskSet: its value, orAbandonedif the task was dropped before it ended. Dropping it abandons only the wait. - Runtime
Unavailable - No executor is current on this thread, so nothing can be scheduled on it.
- Spawner
- The capability to schedule detached work on one executor.
- TaskSet
- A set of detached tasks whose end can be awaited (the liveness-count law).
- Unscheduled
- A future that
spawn_detachedcould not schedule, returned unpolled.
Enums§
- Detached
Error - Why
run_detachedorrun_blockingproduced no output. - Timer
Error - Why the browser could not wait.
Constants§
- UNBOUNDED_
SLEEP - Durations at or beyond this bound (
2³² − 1s, about 136 years) sleep forever.
Traits§
- Maybe
Send - Bound on values moved onto the executor:
Sendon native, unconstrained in the browser. - Maybe
Send Sync - Bound on values shared between tasks:
Send + Syncon native, unconstrained in the browser.
Functions§
- run_
blocking - Start the blocking
operationon the current executor’s blocking thread pool now and return a future of its output (native only: the browser event loop has no blocking pool). - run_
detached - Start
futureon the current executor now and return a future of its output. - sleep
- Wait for
durationon the native timer thread; never fails. - spawn_
detached - Run
futuredetached from the caller on the current executor.