dpp_plugin_traits/meta.rs
1//! Plugin identity ([`PluginMeta`]) and capability declaration
2//! ([`PluginCapability`] / [`PluginCapabilities`]).
3
4use serde::{Deserialize, Serialize};
5
6use crate::version::{AbiVersion, SchemaVersionRange};
7
8/// Static metadata returned by a plugin.
9#[derive(Debug, Clone, Serialize, Deserialize)]
10#[serde(rename_all = "camelCase")]
11pub struct PluginMeta {
12 /// Sector key this plugin handles, e.g. `"textile"`, `"steel"`, `"battery"`.
13 pub sector: String,
14 /// Human-readable plugin name.
15 pub name: String,
16 /// SemVer version string of the plugin itself.
17 pub version: String,
18 /// SPDX license identifier.
19 pub license: String,
20 /// Brief description of what this plugin does.
21 #[serde(skip_serializing_if = "Option::is_none")]
22 pub description: Option<String>,
23 /// Plugin author or organisation.
24 #[serde(skip_serializing_if = "Option::is_none")]
25 pub author: Option<String>,
26 /// URL for plugin documentation or source code.
27 #[serde(skip_serializing_if = "Option::is_none")]
28 pub homepage: Option<String>,
29}
30
31/// Feature flags a plugin may declare support for.
32#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
33#[serde(rename_all = "snake_case")]
34pub enum PluginCapability {
35 /// Can validate sector-specific data against the schema.
36 Validate,
37 /// Can compute compliance metrics (CO2e, repairability, etc.).
38 ComputeMetrics,
39 /// Can generate a passport-ready data payload.
40 GeneratePassport,
41 /// Can perform SVHC / substance-of-concern screening.
42 SubstanceScreening,
43 /// Can compute lifecycle assessment (LCA) metrics.
44 LifecycleAssessment,
45 /// Can map data to Asset Administration Shell (AAS) submodels.
46 AasMapping,
47 /// Custom capability (plugin-defined extension point).
48 Custom(String),
49}
50
51/// Full capability declaration returned by a plugin during negotiation.
52///
53/// The host calls `capabilities()` before dispatching any work to verify
54/// that the plugin supports the required schema version and features.
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(rename_all = "camelCase")]
57pub struct PluginCapabilities {
58 /// The ABI version this plugin was compiled against.
59 pub abi_version: AbiVersion,
60 /// The sector schemas this plugin can handle.
61 pub supported_schemas: Vec<SchemaVersionRange>,
62 /// Feature capabilities this plugin provides.
63 pub capabilities: Vec<PluginCapability>,
64 /// Minimum host ABI version required by this plugin.
65 /// If the host's ABI is below this, the plugin refuses to load.
66 #[serde(skip_serializing_if = "Option::is_none")]
67 pub min_host_version: Option<AbiVersion>,
68 /// Plugin-declared fuel budget per invocation (host caps at DEFAULT_FUEL).
69 /// Plugins needing less computation can set this lower for tighter sandboxing.
70 #[serde(skip_serializing_if = "Option::is_none")]
71 pub max_fuel: Option<u64>,
72 /// Plugin-declared memory cap in bytes per invocation (host caps at DEFAULT_MEMORY_CAP_BYTES).
73 #[serde(skip_serializing_if = "Option::is_none")]
74 pub max_memory_bytes: Option<u64>,
75}