Resource

target

One workload, on one interface of it, that this task's calls go to for as long as the handle is alive.

resource target;

F get-workload-id

get-workload-id: func() -> workload-id;

The workload this handle names.

F get-interface

get-interface: func() -> string;

The interface this handle routes.

F open

open: func(id: workload-id, interface: string) -> option​<target>;

Direct this task's calls on interface to id, or none when that workload is not currently callable on it — it is not running, or it does not export that interface. %interface is spelled as it appears in callable, which is where the pairs come from.

Check this rather than assuming: what callable returns is a snapshot, and a workload can stop between reading it and acting on it. A plugin's own wasi:cli/run dispatch loop races exactly that way every time a workload is undeployed.