Skip to main content

dpp_calc/repairability/thresholds/
ruleset.rs

1//! The [`RepairabilityRuleset`] trait implemented by each concrete ruleset version.
2
3use super::{RepairabilityThresholds, RepairabilityWeights};
4use crate::error::CalcError;
5use crate::repairability::parameters::RepairabilityInputs;
6use crate::ruleset::Ruleset;
7
8/// Ruleset for the simplified repairability heuristic.
9///
10/// Extends [`Ruleset`]; `regulatory_basis()` records the provenance, which for
11/// the heuristic is explicitly non-regulatory. The heuristic-specific data
12/// (weights and A–E band thresholds) is in the two additional methods.
13///
14/// ## Canonical pattern for future methodology traits
15/// ```rust,ignore
16/// pub trait PEFRuleset: Ruleset { ... }
17/// pub trait CfbRuleset: Ruleset { ... }
18/// ```
19pub trait RepairabilityRuleset: Ruleset {
20    fn weights(&self) -> &RepairabilityWeights;
21    fn thresholds(&self) -> &RepairabilityThresholds;
22
23    /// Validate parameter combinations that are incoherent per this ruleset.
24    ///
25    /// Called after range validation. Default: no cross-field constraints.
26    /// Override to enforce coherence rules (e.g. the disassembly/spare-parts
27    /// dependency).
28    fn validate_cross_fields(&self, _inputs: &RepairabilityInputs) -> Result<(), CalcError> {
29        Ok(())
30    }
31}