dpp_aas/lib.rs
1//! `dpp-aas` — Asset Administration Shell (IDTA) projection of a passport.
2//!
3//! The IDTA AAS metamodel (IDTA-01001-3-0) is the interoperability standard
4//! used by EU Industry 4.0 and Catena-X data spaces. Passports published
5//! through Odal Node must be expressible as AAS shells + submodels for
6//! ecosystem registry interoperability.
7//!
8//! Pure, stateless crate with no I/O or network dependencies. Compiles to both
9//! `std` and `wasm32`.
10//!
11//! ## Key types
12//!
13//! - [`AasShell`] — top-level container; holds [`AssetInformation`] (linking the
14//! shell to the physical product via GS1 GTIN) and references to its submodels.
15//! - [`AasSubmodel`] — one logical grouping of product data, e.g.
16//! `ProductIdentification`, `EnvironmentalImpact`, `BatteryTechnicalData`.
17//! - [`AasSubmodelElement`] — leaf value ([`AasProperty`]), group
18//! ([`AasCollection`]), or external link ([`AasReference`]).
19//!
20//! ## Primary entry point
21//!
22//! [`build_aas_from_passport`] maps a typed [`Passport`](dpp_domain::Passport)
23//! plus a GS1 GTIN string into a complete `(AasShell, Vec<AasSubmodel>)` ready
24//! for serialisation or registry submission. The shell references its submodels
25//! by ID following the IDTA AAS Part 2 API pattern — shell and submodels are
26//! served from separate endpoints.
27//!
28//! Always produces five core submodels: `ProductIdentification`,
29//! `ManufacturerInformation`, `EnvironmentalImpact`, `MaterialComposition`,
30//! `Repairability`. If `passport.sector_data` is `Some`, a sixth
31//! sector-specific submodel is appended (`BatteryTechnicalData`,
32//! `TextileMaterialDeclaration`, `ElectronicsProductData`, or a generic
33//! `SectorData` fallback for sectors without a dedicated template yet).
34//!
35//! The lower-level [`map_dpp_to_aas_submodel`] remains available as a generic
36//! JSON-to-submodel escape hatch.
37//!
38//! # This crate emits identifiers, not conformance
39//!
40//! Producing AAS-shaped output is not the same as conforming to an IDTA
41//! specification, and nothing here should be described as IDTA-conformant.
42//!
43//! Every `semanticId` emitted is either in the `urn:odal-node:` namespace — our
44//! own concept, honestly named — or carries a provenance record in
45//! `semantic_ids/allowlist.json` naming who verified it against the authority's
46//! own published source, and when. That rule is enforced by a test, not by a
47//! comment, because six identifiers claiming IDTA and ECLASS authority once sat
48//! here behind comments asking someone to check them.
49//!
50//! Split out of [`dpp-digital-link`], which retains the GS1 parser this used to
51//! ship alongside.
52//!
53//! [`dpp-digital-link`]: https://docs.rs/dpp-digital-link
54
55pub mod semantic_ids;
56
57mod builder;
58mod mapper;
59mod model;
60mod property;
61mod sectors;
62mod templates;
63#[cfg(test)]
64mod tests;
65
66pub use builder::build_aas_from_passport;
67pub use mapper::map_dpp_to_aas_submodel;
68pub use model::{
69 AasCollection, AasDataType, AasProperty, AasReference, AasSemId, AasSemIdKey, AasShell,
70 AasSubmodel, AasSubmodelElement, AasSubmodelRef, AssetInformation, SpecificAssetId,
71};
72pub use property::{boolean_property, double_property, integer_property, string_property};
73pub use templates::{SubmodelTemplate, placeholder_templates, sector_submodel_template};
74
75/// Compile-checks this crate's README examples.
76///
77/// A README example is a public claim about the API, and nothing else in the
78/// build compiles one. Without this, a README can advertise a function that
79/// does not exist — which is exactly what happened before this harness landed.
80#[cfg(doctest)]
81#[doc = include_str!("../README.md")]
82struct ReadmeDoctests;