pub trait CapabilityDispatcher: Send + Sync {
// Required method
fn dispatch(
&self,
tokio_handle: &Handle,
target: &str,
payload: Vec<u8>,
) -> Result<Vec<u8>, String>;
}Expand description
Executes one capability call: decode payload, call the real
implementor injected behind this dispatcher, encode the result back to
bytes. A leaf operation (ADR-001) — never triggers a second capability
call on the guest’s behalf.
target names what to call within this dispatcher’s own bound scope
(a "pkg.Service/Method" for grpc-egress, a query name for
database, a secret name for secrets, …) — never an open-ended
address the dispatcher itself resolves.
Returns a plain String error, not a typed one: every dispatcher
wraps a different real implementor’s own error type, and this port has
no reason to unify them into one enum. Zero implementation here.
Required Methods§
Sourcefn dispatch(
&self,
tokio_handle: &Handle,
target: &str,
payload: Vec<u8>,
) -> Result<Vec<u8>, String>
fn dispatch( &self, tokio_handle: &Handle, target: &str, payload: Vec<u8>, ) -> Result<Vec<u8>, String>
Dispatch one call to target with payload, returning the raw
response bytes.
tokio_handle lets an implementor whose real call is async re-enter
a tokio runtime from a context (e.g. a component’s own dedicated OS
thread) that has none of its own ambiently.
§Errors
Returns a human-readable message naming what failed.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".