pub enum AbiResult {
Ok(Value),
Error(PluginError),
}Expand description
JSON envelope wrapping the outcome of a fallible plugin ABI call.
The low-level Wasm exports (validate, calculate_metrics,
generate_passport) cannot return a Rust Result across the C ABI, so the
outcome is serialised as this externally-tagged enum. On success, ok
carries the method’s return value (a PluginResult for
calculate_metrics, the normalised payload for generate_passport, or
null for validate). On failure, error carries a structured
PluginError. The host deserialises this to recover the typed result.
{ "ok": { "co2eScore": 85.4, "complianceStatus": "NOT_ASSESSED", ... } }
{ "error": { "ValidationErrors": [ { "field": "/gtin", "code": "missing", ... } ] } }Variants§
Ok(Value)
Error(PluginError)
Implementations§
Source§impl AbiResult
impl AbiResult
Sourcepub fn ok<T: Serialize>(value: &T) -> Self
pub fn ok<T: Serialize>(value: &T) -> Self
Build a successful response by serialising value.
If serialisation fails — e.g. a plugin inserted a non-finite f64 into
PluginResult.metrics, bypassing the with_metric finite-value guard —
this returns the AbiResult::Error variant rather than a spurious
Ok(null), so the failure is not silently swallowed.