Skip to content

fidius-host::executor::python

Rust

Pyo3Executor — the Python execution backend, behind the python feature.

Thin host-side wrapper over fidius_python::PythonPluginHandle (which owns the embedded-interpreter dispatch) that adapts it to the crate::executor traits so Python plugins flow through the same crate::handle::PluginHandle as cdylib plugins.

Typed calls cross as a self-describing Value. The Python layer already speaks self-describing JSON (call_typed_json), so the adapter bridges Value ↔ JSON with serde_json — Value serialises to exactly the JSON the Python value_bridge expects, so this is behaviour-identical to the pre-unification path (serde_json::to_vec(input) → call_typed_json), just routed through the neutral Value currency.

pub

Python-backed executor: an embedded-interpreter plugin handle plus the host-facing PluginInfo (built from the package manifest + interface descriptor at load time).

pub

fn new(py: PythonPluginHandle, info: PluginInfo) -> Self

Wrap a loaded PythonPluginHandle with its owned metadata.

Source
pub fn new(py: PythonPluginHandle, info: PluginInfo) -> Self {
Self { py, info }
}

pub

fn call_client_streaming(
&self,
method: usize,
items: Box<dyn Iterator<Item = serde_json::Value> + Send>,
args: Value,
) -> Result<Value, CallError>

Client-streaming (FIDIUS-I-0030 CS2.4): the host produces items; the plugin method receives them as a host-fed iterator + returns a value. Pivots through JSON like the unary path.

Source
pub fn call_client_streaming(
&self,
method: usize,
items: Box<dyn Iterator<Item = serde_json::Value> + Send>,
args: Value,
) -> Result<Value, CallError> {
let args_json =
serde_json::to_vec(&args).map_err(|e| CallError::Serialization(e.to_string()))?;
let out = self
.py
.call_client_streaming_json(method, items, &args_json)
.map_err(CallError::from)?;
serde_json::from_slice(&out).map_err(|e| CallError::Deserialization(e.to_string()))
}

pub

fn call_bidi_streaming(
&self,
method: usize,
items: Box<dyn Iterator<Item = serde_json::Value> + Send>,
args: Value,
) -> Result<crate::stream::ChunkStream, CallError>

Bidirectional streaming (FIDIUS-I-0032 / ADR-0010): the host produces items (the plugin’s input iterator) and consumes the plugin’s returned generator as a ChunkStream. Pulling the output pulls the input — the synchronous lazy-pull composition. args are the non-stream args.

Source
pub fn call_bidi_streaming(
&self,
method: usize,
items: Box<dyn Iterator<Item = serde_json::Value> + Send>,
args: Value,
) -> Result<crate::stream::ChunkStream, CallError> {
let args_json =
serde_json::to_vec(&args).map_err(|e| CallError::Serialization(e.to_string()))?;
let stream = self
.py
.call_bidi_streaming_start(method, items, &args_json)
.map_err(CallError::from)?;
Ok(pump_python_stream(stream))
}