ddex_core/models/versions/
ern_42.rs

1// core/src/models/versions/ern_42.rs
2//! ERN 4.2 specific model variations
3
4use super::common::ValidityPeriod42;
5use crate::models::common::{Identifier, LocalizedString};
6use chrono::{DateTime, Utc};
7use serde::{Deserialize, Serialize};
8
9/// MessageHeader for ERN 4.2
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct MessageHeader42 {
12    pub message_id: String,
13    pub message_thread_id: Option<String>, // Optional in 4.2
14    pub message_type: MessageType42,
15    pub message_sender: PartyDescriptor42,
16    pub message_recipient: PartyDescriptor42,
17    pub message_created_date_time: DateTime<Utc>,
18    pub message_audit_trail: Option<MessageAuditTrail42>, // New in 4.2
19    pub message_control_type: Option<MessageControlType42>,
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub enum MessageType42 {
24    NewReleaseMessage,
25    CatalogListMessage,
26    UpdateReleaseMessage,
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
30pub enum MessageControlType42 {
31    LiveMessage,
32    TestMessage,
33}
34
35/// PartyDescriptor for ERN 4.2 (enhanced)
36#[derive(Debug, Clone, Serialize, Deserialize)]
37pub struct PartyDescriptor42 {
38    pub party_name: Vec<LocalizedString>, // Array in 4.2
39    pub party_id: Vec<Identifier>,        // Array of typed identifiers
40    pub trading_name: Option<String>,     // New in 4.2
41}
42
43/// MessageAuditTrail introduced in ERN 4.2
44#[derive(Debug, Clone, Serialize, Deserialize)]
45pub struct MessageAuditTrail42 {
46    pub message_audit_trail_event: Vec<MessageAuditTrailEvent42>,
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize)]
50pub struct MessageAuditTrailEvent42 {
51    pub message_audit_trail_event_type: String,
52    pub date_time: DateTime<Utc>,
53    pub responsible_party_reference: Option<String>,
54}
55
56/// DealTerms for ERN 4.2 (standard structure)
57#[derive(Debug, Clone, Serialize, Deserialize)]
58pub struct DealTerms42 {
59    pub deal_reference: Option<String>,     // New in 4.2
60    pub commercial_model_type: Vec<String>, // Array in 4.2
61    pub use_type: Vec<String>,
62    pub territory_code: Vec<TerritoryCode42>,
63    pub distribution_channel: Vec<DistributionChannel42>,
64    pub price_information: Vec<PriceInformation42>,
65    pub validity_period: Option<ValidityPeriod42>,
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct TerritoryCode42 {
70    pub territory_code: String,
71    pub excluded: bool,
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
75pub struct DistributionChannel42 {
76    pub distribution_channel_type: String,
77    pub distribution_channel_name: Option<String>,
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
81pub struct PriceInformation42 {
82    pub price_type: String,
83    pub price_range_type: Option<String>,
84    pub price: Price42,
85}
86
87#[derive(Debug, Clone, Serialize, Deserialize)]
88pub struct Price42 {
89    pub amount: f64,
90    pub currency_code: String,
91    pub price_tier: Option<String>, // New in 4.2
92}
93
94/// TechnicalInstantiation introduced in ERN 4.2
95#[derive(Debug, Clone, Serialize, Deserialize)]
96pub struct TechnicalInstantiation42 {
97    pub technical_resource_details_reference: String,
98    pub coding_type: Option<String>,
99    pub bit_rate: Option<i32>,
100    pub file: Option<File42>,
101}
102
103#[derive(Debug, Clone, Serialize, Deserialize)]
104pub struct File42 {
105    pub file_name: String,
106    pub file_path: Option<String>,
107    pub hash_sum: Option<HashSum42>,
108}
109
110#[derive(Debug, Clone, Serialize, Deserialize)]
111pub struct HashSum42 {
112    pub hash_sum: String,
113    pub hash_sum_algorithm_type: String,
114}