fidius-host::executor
Rust
PluginExecutor — the dispatch seam across execution backends.
Fidius historically carried one dispatch implementation per backend: the
cdylib vtable/FFI path lived inside PluginHandle, and the Python (PyO3)
path lived in a separate PythonPluginHandle in fidius-python. This
module collapses that duplication: each backend is an executor, and the
caller-facing crate::handle::PluginHandle wraps them in an enum
(Backend) so its generic call_method<I, O> can serialise with each
backend’s native currency.
Why an enum, not Box<dyn> — and why two traits
The backends do not share a typed wire. cdylib decodes concrete-type
bincode (not self-describing — it can’t be reconstructed from an erased
value), while Python (and the future WASM component backend) consume a
self-describing fidius_core::Value. A single call(method, Value) trait
method therefore cannot serve cdylib without breaking its ABI (see
FIDIUS-A-0003 / FIDIUS-I-0021 amendment). So:
PluginExecutoris the common surface every backend shares: metadata plus the raw byte path. For cdylib,call_rawis also the carrier for typed calls (the wrapper bincode-wraps the concrete type).ValueExecutoradds the typedfidius_core::Valuecall, implemented only by the self-describing backends (Python, WASM). cdylib does not implement it —PluginHandleroutes cdylib typed calls through its own bincodecall_method, keeping the bytes byte-identical to pre-refactor.
Re-exports
Section titled “Re-exports”CdylibExecutorPyo3Executorprecompile_componentvalidate_componentEgressDeniedEgressPolicyResponseDirectiveTcpTargetWasmComponentExecutorWasmMethod
Traits
Section titled “Traits”trait PluginExecutor
Section titled “trait PluginExecutor”pub
Supertraits: Send + Sync
The surface every execution backend shares.
Implementations must be Send + Sync: methods take &self, so a handle can
be shared across threads as long as the backend is internally thread-safe.
Methods
Section titled “Methods”fn info(&self) -> &PluginInfoOwned metadata describing the loaded plugin.
Source
fn info(&self) -> &PluginInfo;method_count
Section titled “method_count”fn method_count(&self) -> u32Number of methods the plugin exposes, in interface (vtable) order.
Source
fn method_count(&self) -> u32;call_raw
Section titled “call_raw”fn call_raw( &self, method: usize, input: &[u8],) -> Result<Vec<u8>, CallError>Raw bulk-bytes dispatch for #[wire(raw)] methods: opaque bytes in, opaque bytes out, no per-element marshalling. Opaque bytes are language-neutral (a WIT list<u8>), so this is uniform across backends.
Source
fn call_raw(&self, method: usize, input: &[u8]) -> Result<Vec<u8>, CallError>;trait ValueExecutor
Section titled “trait ValueExecutor”pub
Supertraits: PluginExecutor
Backends whose typed boundary is the self-describing Value model — Python today, and the Phase-2 WASM component executor.
cdylib deliberately does not implement this: its typed path is
concrete-type bincode, which Value cannot reproduce. PluginHandle
dispatches cdylib typed calls directly via bincode instead.
Methods
Section titled “Methods”fn call(&self, method: usize, args: Value) -> Result<Value, CallError>Typed dispatch by method index. Arguments and returns cross as a self-describing Value; the backend maps it to its native form (Python → PyObject, WASM → component::Val).
Source
fn call(&self, method: usize, args: Value) -> Result<Value, CallError>;