Skip to main content

Module async_request

Module async_request 

Source
Expand description

Portable state machine for frame-bounded async requests.

Shell-side session state often needs to track “a request is in flight; when it completes, the result lands here” — the omnibar provider mailbox, deferred intent resolution, clip-capture round trips, etc. The pre-M4 pattern embedded crossbeam_channel receivers inside the session state, which is fine on desktop but doesn’t compile to wasm32-unknown-unknown (crossbeam_channel needs std::thread).

AsyncRequestState<T> is the portable replacement: pure data, no threading primitives inside. A host-side driver owns the actual channel / future / fetch, and deposits results into this state when ready. The host session just reads and reacts.

Concretely:

  • Shell state holds AsyncRequestState<T>. Calling code transitions via arm_pending, resolve, interrupt, clear. Generation counter lets the state reject stale late results from requests that have since been superseded.
  • Host driver (one per session or one per request kind) owns the concrete async machinery — crossbeam_channel::Receiver<T> / tokio::sync::oneshot / futures::channel / etc. Polls at frame boundaries and calls resolve / interrupt on the state it shepherds.

The state type has no threading or time dependencies, so it is safe to place inside types that belong in portable session-state sub-crate targeting wasm32-unknown-unknown and wasip2.

Enums§

AsyncRequestState
Frame-bounded state of a host-driven async request.