Skip to main content

Module picker_source

Module picker_source 

Source
Expand description

PH7.4c.2 — the WasmPickerSource host adapter (the create path).

Wraps a plugin’s picker exports (driven through the PickerClient bridge, PH7.4c.1b) as an Arc<dyn PickerSourceGenerator> so a plugin source is indistinguishable from a first-party one at the PickerRegistry (register_generator). The boundary conversions are PH7.4a’s WitBoundary + project_picker_context; this adapter only sequences them against the trait’s sync/async contract.

§Mapping the trait onto an async, actor-bound guest

PickerSourceGenerator’s methods are synchronous, but the guest exports are async and bound to the plugin’s actor task (picker_task.rs). The three methods resolve that mismatch differently:

  • spec is fetched once at connect time and cached natively, so the sync spec(&self) -> &PickerSourceSpec is a borrow — no per-call guest hop.
  • init returns PickerInitResult::Future: the sync prelude projects the borrowed context into an owned WIT record (§4.2) and moves it into a 'static future that awaits client.init off-thread, then converts the WIT candidate pairs back. This drops straight into the host’s existing pending_picker_init drain.
  • accept returns Some from accept_async: the same sync-prelude-then-future shape, awaiting client.accept. The host applies the outcome via the pending-accept drain. The synchronous accept is a defensive tripwire — the host always prefers accept_async when it returns Some, so a plugin accept never blocks the actor thread (paramount #4).

Structs§

WasmPickerSource
An Arc<dyn PickerSourceGenerator>-ready adapter over ONE of a picker plugin’s registered sources.

Functions§

connect_picker_sources
Convenience: drive registration and wrap each declared source as the Arc<dyn PickerSourceGenerator> the PickerRegistry stores.