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//!   and [`PluginIdentity`], the per-plugin fields its default `meta()` uses.
28
29mod error;
30mod meta;
31mod plugin;
32mod result;
33#[cfg(test)]
34mod tests;
35mod version;
36
37pub use error::{PluginError, PluginFieldError};
38pub use meta::{PluginCapabilities, PluginCapability, PluginMeta};
39pub use plugin::{DppSectorPlugin, PluginIdentity, PluginInput};
40pub use result::{
41    AbiResult, METRIC_CO2E_SCORE, METRIC_RECYCLED_CONTENT_PCT, METRIC_REPAIRABILITY_INDEX,
42    PluginComplianceStatus, PluginFinding, PluginResult,
43};
44pub use version::{
45    ABI_VERSION_MAJOR, ABI_VERSION_MINOR, AbiVersion, CompatibilityStatus, SchemaVersionRange,
46    check_compatibility,
47};
48
49/// Compile-checks this crate's README examples.
50///
51/// A README example is a public claim about the API, and nothing else in the
52/// build compiles one. Without this, a README can advertise a function that
53/// does not exist — which is exactly what happened before this harness landed.
54#[cfg(doctest)]
55#[doc = include_str!("../README.md")]
56struct ReadmeDoctests;