Skip to content

fidius-guest::value

Rust

Value — a neutral, self-describing value tree for the plugin boundary.

Every fidius execution backend dispatches typed method calls through a single PluginExecutor::call(method, Value) -> Value seam (see fidius-host). Value is the lingua franca each backend maps to its native representation:

  • cdylib: Value → bincode → vtable FFI → bincode → Value
  • python: Value → PyObject → call → PyObject → Value
  • wasm: Value → wasmtime component::Val (Canonical ABI) → Value

The host’s generic call_method<I, O> stays caller-identical by going I → Value (to_value) then Value → O (from_value) around the executor.

Layering rule: Value lives in fidius-core and is deliberately free of any backend dependency. Only the WASM executor (Phase 2) maps it to wasmtime::component::Val; cdylib and Python never see wasmtime.

The variant set mirrors the WebAssembly Component Model value space so the Phase-2 mapping is mechanical: distinct signed/unsigned integer widths, f32/f64, char, string, list<u8> as Value::Bytes, lists, records, options, and variants.

pub

Derives: Debug, thiserror::Error

Error produced while converting to or from Value.

Name Type Description
0 String

pub

A self-describing value crossing the plugin-call boundary.

Construct one from any Serialize type with to_value and read it back into any DeserializeOwned type with from_value.

  • Bool - Boolean.
  • S8 - Signed 8-bit integer.
  • S16 - Signed 16-bit integer.
  • S32 - Signed 32-bit integer.
  • S64 - Signed 64-bit integer.
  • U8 - Unsigned 8-bit integer.
  • U16 - Unsigned 16-bit integer.
  • U32 - Unsigned 32-bit integer.
  • U64 - Unsigned 64-bit integer.
  • F32 - 32-bit float.
  • F64 - 64-bit float.
  • Char - Unicode scalar value.
  • String - UTF-8 string.
  • Bytes - Opaque byte string (list<u8> in WIT terms).
  • Option - Optional value (none/some).
  • List - Ordered sequence — serde seqs, tuples, and tuple structs land here.
  • Record - Named fields — serde structs and string-keyed maps land here. Field order is preserved (insertion order).
  • Map - General key/value map for non-string keys.
  • Variant - A tagged enum case. value carries the payload: Value::Unit for a unit variant, the inner value for a newtype variant, a Value::List for a tuple variant, or a Value::Record for a struct variant.
  • Unit - The unit value — serde () and unit structs.

pub

fn to_value<T: Serialize>(value: &T) -> Result<Value, ValueError>

Convert any Serialize type into a Value.

Source
pub fn to_value<T: Serialize>(value: &T) -> Result<Value, ValueError> {
value.serialize(ValueSerializer)
}

pub

fn from_value<T>(value: Value) -> Result<T, ValueError>
where
T: de::DeserializeOwned,

Convert a Value into any Deserialize type.

Source
pub fn from_value<T>(value: Value) -> Result<T, ValueError>
where
T: de::DeserializeOwned,
{
T::deserialize(value)
}