Skip to main content

dpp_plugin_traits/
lib.rs

1//! Host/guest ABI contract for Odal Node sector plugins.
2//!
3//! Plugins implement [`DppSectorPlugin`] and export the three entry points
4//! as `extern "C"` symbols. The host invokes them through the wasmtime
5//! component model or directly via the low-level ABI defined below.
6//!
7//! Data crosses the host/guest boundary as JSON strings over a shared-memory
8//! slice, so the low-level ABI itself is just integer pointer/length pairs.
9//! (The crate uses `std` types — `String`, `Vec`, `HashMap` — so it is not
10//! `no_std`.)
11//!
12//! ## Versioning
13//!
14//! Every plugin declares which ABI version and schema versions it supports
15//! via [`PluginCapabilities`]. The host uses this for compatibility checks
16//! before dispatching any calls.
17//!
18//! ## Module layout
19//!
20//! - `version` — [`AbiVersion`], [`SchemaVersionRange`], [`CompatibilityStatus`],
21//!   and [`check_compatibility`] (ABI/schema/capability negotiation).
22//! - `meta` — [`PluginMeta`], [`PluginCapability`], [`PluginCapabilities`].
23//! - `result` — [`PluginComplianceStatus`], [`PluginFinding`], [`PluginResult`],
24//!   [`AbiResult`] (the call-outcome envelope).
25//! - `error` — [`PluginError`], [`PluginFieldError`].
26//! - `plugin` — [`DppSectorPlugin`], the trait a plugin author implements.
27
28mod error;
29mod meta;
30mod plugin;
31mod result;
32#[cfg(test)]
33mod tests;
34mod version;
35
36pub use error::{PluginError, PluginFieldError};
37pub use meta::{PluginCapabilities, PluginCapability, PluginMeta};
38pub use plugin::{DppSectorPlugin, PluginInput};
39pub use result::{
40    AbiResult, METRIC_CO2E_SCORE, METRIC_RECYCLED_CONTENT_PCT, METRIC_REPAIRABILITY_INDEX,
41    PluginComplianceStatus, PluginFinding, PluginResult,
42};
43pub use version::{
44    ABI_VERSION_MAJOR, ABI_VERSION_MINOR, AbiVersion, CompatibilityStatus, SchemaVersionRange,
45    check_compatibility,
46};