ddex_core/models/versions/
mod.rs

1// core/src/models/versions/mod.rs
2//! Version-specific model variations for ERN standards
3
4use serde::{Deserialize, Serialize};
5
6pub mod version;
7pub use version::ERNVersion;
8
9pub mod ern_382;
10pub mod ern_42;
11pub mod ern_43;
12pub mod common;
13
14/// Version-specific differences in DDEX ERN
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct VersionDifferences {
17    pub version: ERNVersion,
18    pub namespace_uri: String,
19    pub schema_location: String,
20    pub features: VersionFeatures,
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
24pub struct VersionFeatures {
25    // Features introduced or changed in each version
26    pub supports_message_audit_trail: bool,
27    pub supports_release_profile: bool,
28    pub supports_technical_instantiation: bool,
29    pub supports_deal_reference: bool,
30    pub supports_resource_group: bool,
31    pub supports_chapter_information: bool,
32    pub deal_terms_structure: DealTermsVersion,
33    pub party_descriptor_type: PartyDescriptorVersion,
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize)]
37pub enum DealTermsVersion {
38    Legacy,     // 3.8.2 style
39    Standard,   // 4.2 style
40    Extended,   // 4.3 style with additional fields
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
44pub enum PartyDescriptorVersion {
45    Basic,      // 3.8.2
46    Enhanced,   // 4.2+
47}
48
49impl VersionDifferences {
50    pub fn for_version(version: ERNVersion) -> Self {
51        match version {
52            ERNVersion::V3_8_2 => Self {
53                version,
54                namespace_uri: "http://ddex.net/xml/ern/382".to_string(),
55                schema_location: "http://ddex.net/xml/ern/382/release-notification.xsd".to_string(),
56                features: VersionFeatures {
57                    supports_message_audit_trail: false,
58                    supports_release_profile: false,
59                    supports_technical_instantiation: false,
60                    supports_deal_reference: false,
61                    supports_resource_group: false,
62                    supports_chapter_information: false,
63                    deal_terms_structure: DealTermsVersion::Legacy,
64                    party_descriptor_type: PartyDescriptorVersion::Basic,
65                },
66            },
67            ERNVersion::V4_2 => Self {
68                version,
69                namespace_uri: "http://ddex.net/xml/ern/42".to_string(),
70                schema_location: "http://ddex.net/xml/ern/42/release-notification.xsd".to_string(),
71                features: VersionFeatures {
72                    supports_message_audit_trail: true,
73                    supports_release_profile: true,
74                    supports_technical_instantiation: true,
75                    supports_deal_reference: true,
76                    supports_resource_group: false,
77                    supports_chapter_information: false,
78                    deal_terms_structure: DealTermsVersion::Standard,
79                    party_descriptor_type: PartyDescriptorVersion::Enhanced,
80                },
81            },
82            ERNVersion::V4_3 => Self {
83                version,
84                namespace_uri: "http://ddex.net/xml/ern/43".to_string(),
85                schema_location: "http://ddex.net/xml/ern/43/release-notification.xsd".to_string(),
86                features: VersionFeatures {
87                    supports_message_audit_trail: true,
88                    supports_release_profile: true,
89                    supports_technical_instantiation: true,
90                    supports_deal_reference: true,
91                    supports_resource_group: true,
92                    supports_chapter_information: true,
93                    deal_terms_structure: DealTermsVersion::Extended,
94                    party_descriptor_type: PartyDescriptorVersion::Enhanced,
95                },
96            },
97        }
98    }
99}