dpp_rules/lib.rs
1//! `dpp-rules` — pure EU ESPR cross-field regulatory rules.
2//!
3//! Rules are grouped by sector module. Batteries, textiles, and electronics are
4//! the active sectors; all others have placeholder modules and will be populated
5//! in a later phase.
6//!
7//! Inputs are primitive borrowing views so each caller adapts its own
8//! representation — typed structs in core, `serde_json::Value` fields in
9//! plugins — without this crate depending on either.
10//!
11//! See `docs/architecture/SECTOR-MODEL-CONSOLIDATION.md` §7.
12//!
13//! The `bundle` feature (off by default) adds the ruleset-bundle format +
14//! verification seam (the `bundle` module — conditionally compiled, so not
15//! linked here) and pulls in `std` — see that module's docs.
16
17#![cfg_attr(not(feature = "bundle"), no_std)]
18#![forbid(unsafe_code)]
19
20extern crate alloc;
21
22// Only needed when `no_std` is actually active (default build); when the
23// `bundle` feature is on, `no_std` is off and `std` is already available.
24#[cfg(test)]
25extern crate std;
26
27// Shared helpers (cross-sector utilities).
28pub mod common;
29
30// Chemical substance rules — REACH, RoHS, EU 2026/405.
31// SVHC lives here rather than under any single sector because REACH Art. 33
32// applies across textiles, electronics, toys, construction, and more.
33pub mod chemicals;
34
35// Active sectors.
36pub mod batteries;
37pub mod electronics;
38pub mod textiles;
39
40// Placeholder sectors — rules to be implemented in a later phase.
41pub mod construction;
42pub mod metals;
43pub mod toys;
44
45// Ruleset-bundle format + verification seam (signed, versioned Compliance
46// Current bundles). Optional: signing and hot-swap runtime state stay
47// engine-side; this crate only carries the open format + fail-closed verify.
48#[cfg(feature = "bundle")]
49pub mod bundle;
50
51// ── Crate-root re-exports ────────────────────────────────────────────────────
52// Preserved for backward compatibility with existing callers
53// (dpp-domain adapters, dpp-plugin-sdk::rules).
54
55pub use chemicals::cas::validate_cas_format;
56pub use chemicals::surfactants::{
57 SURFACTANT_BANDS, SurfactantInput, surfactant_band_valid, validate_surfactants,
58};
59pub use chemicals::svhc::{
60 ECHA_CANDIDATE_LIST, SVHC_THRESHOLD_PCT, SvhcFinding, SvhcFindingKind, SvhcInput,
61 check_svhc_declarations, validate_svhc_substances,
62};
63pub use common::country::country_code_valid;
64pub use textiles::fibre::{
65 FIBRE_SUM_TOLERANCE, FibreInput, fibre_sum_ok, validate_fibre_composition,
66};