Skip to main content

kmp_plugin_api/
lib.rs

1//! Stable hexagonal boundary for KMP evidence interpretation plugins.
2//!
3//! Domain value objects carry invariants, application DTOs define the wire
4//! contract, and ports define behavior supplied by plugin adapters. Storage,
5//! traversal and runtime infrastructure remain outside this crate.
6
7pub mod application;
8pub mod domain;
9pub mod ports;
10
11pub use application::dto::derivation_operand::DerivationOperand;
12pub use application::dto::derivation_request::DerivationRequest;
13pub use application::dto::derivation_result::DerivationResult;
14pub use application::dto::evidence_fragment::EvidenceFragment;
15pub use application::dto::evidence_interpretation_input::EvidenceInterpretationInput;
16pub use application::dto::evidence_interpretation_output::EvidenceInterpretationOutput;
17pub use application::dto::interpreted_value_mention::InterpretedValueMention;
18pub use domain::calendar_date::CalendarDate;
19pub use domain::currency_code::CurrencyCode;
20pub use domain::derivation_operation::DerivationOperation;
21pub use domain::evidence_segment_kind::EvidenceSegmentKind;
22pub use domain::interpretation_error::InterpretationError;
23pub use domain::interpreted_value::InterpretedValue;
24pub use domain::math_expression_notation::MathExpressionNotation;
25pub use domain::operand_label::OperandLabel;
26pub use domain::operand_role::OperandRole;
27pub use domain::source_code_segment_kind::SourceCodeSegmentKind;
28pub use domain::text_span::TextSpan;
29pub use ports::evidence_derivation_plugin::EvidenceDerivationPlugin;
30pub use ports::evidence_value_plugin::EvidenceValuePlugin;
31
32#[cfg(test)]
33mod tests {
34    use super::*;
35
36    #[test]
37    fn public_builders_preserve_the_existing_contract() {
38        let operand = DerivationOperand::included(
39            "turn:42",
40            InterpretedValue::number(3.0, Some("items".to_string())),
41        )
42        .with_role(OperandRole::CountedItem)
43        .with_entity("payment-service");
44
45        assert_eq!(CurrencyCode::new(" usd ").expect("code").as_str(), "USD");
46        assert_eq!(operand.ref_id, "turn:42");
47        assert_eq!(operand.label, OperandLabel::Include);
48        assert_eq!(operand.role, Some(OperandRole::CountedItem));
49        assert_eq!(operand.entity.as_deref(), Some("payment-service"));
50    }
51}