Skip to main content

Crate dpp_plugin_sdk

Crate dpp_plugin_sdk 

Source
Expand description

Guest-side SDK for Odal Node Wasm sector plugins.

A sector plugin author implements the DppSectorPlugin trait from dpp-plugin-traits and invokes export_plugin! once. The macro generates the full low-level Wasm ABI (alloc, dealloc, metadata, describe, validate, calculate_metrics, generate_passport) and wires each export to the corresponding trait method. Plugins no longer hand-roll the ABI shim or redefine their own output structs — they speak the shared contract.

§Why describe()

The host calls describe() immediately after loading a plugin to read its PluginCapabilities (ABI version, supported schema versions, feature capabilities) and run dpp_plugin_traits::check_compatibility before dispatching any work. This is what makes the version registry enforceable at the Wasm boundary rather than aspirational.

§ABI summary

ExportSignatureReturns (JSON)
alloc(len: u32) -> u32pointer to len bytes
dealloc(ptr: u32, len: u32)
metadata() -> u64PluginMeta
describe() -> u64PluginCapabilities
validate(ptr: u32, len: u32) -> u64AbiResult (ok: null / error)
calculate_metrics(ptr: u32, len: u32) -> u64AbiResult (ok: PluginResult)
generate_passport(ptr: u32, len: u32) -> u64AbiResult (ok: payload)

Every -> u64 return packs the output buffer as (out_ptr << 32) | out_len. The host reads the JSON, then frees the buffer via dealloc.

§Module layout

  • abi — the low-level linear-memory ABI (alloc/dealloc/buffer packing).
  • codec — pure, host-testable JSON glue (*_bytes functions).
  • entry — the run_* ABI entry-point wrappers export_plugin! calls.
  • validate — shared field-validation helpers.

Re-exports§

pub use dpp_plugin_traits as traits;
pub use dpp_rules as rules;

Modules§

abi
Low-level linear-memory ABI: allocation, deallocation, and buffer packing across the Wasm host/guest boundary.
validate
Reusable field validation for sector plugins.

Macros§

export_plugin
Generate the full Wasm ABI for a sector plugin.

Enums§

PluginComplianceStatus
Typed compliance determination returned by a plugin.

Constants§

METRIC_CO2E_SCORE
Well-known metric key for CO₂e score (kg CO₂e per functional unit).
METRIC_RECYCLED_CONTENT_PCT
Well-known metric key for recycled content percentage (0.0–100.0).
METRIC_REPAIRABILITY_INDEX
Well-known metric key for the repairability index (0.0–10.0; non-regulatory heuristic, not EN 45554 / EU 2023/1669).

Functions§

calculate_metrics_bytes
Run calculate_metrics and serialise the AbiResult envelope.
describe_bytes
Serialise the plugin’s PluginCapabilities to JSON bytes.
generate_passport_bytes
Run generate_passport and serialise the AbiResult envelope.
metadata_bytes
Serialise the plugin’s PluginMeta to JSON bytes.
run_calculate_metrics
Safety
run_describe
run_generate_passport
Safety
run_metadata
run_validate
Safety
validate_bytes
Run validate_input and serialise the AbiResult envelope.