ddex_core/models/graph/
message.rs

1// core/src/models/graph/message.rs
2//! ERN Message types
3
4use super::{Deal, MessageHeader, Party, Release, Resource};
5use crate::models::{versions::ERNVersion, AttributeMap, Comment, Extensions};
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct ERNMessage {
10    pub message_header: MessageHeader,
11    pub parties: Vec<Party>,
12    pub resources: Vec<Resource>,
13    pub releases: Vec<Release>,
14    pub deals: Vec<Deal>,
15    pub version: ERNVersion,
16    pub profile: Option<ERNProfile>,
17    pub message_audit_trail: Option<MessageAuditTrail>,
18    /// All XML attributes (standard and custom) for the root element
19    pub attributes: Option<AttributeMap>,
20    /// Comprehensive extension preservation system
21    pub extensions: Option<Extensions>,
22    /// Legacy extensions (for backward compatibility)
23    pub legacy_extensions: Option<std::collections::HashMap<String, String>>,
24    pub comments: Option<Vec<Comment>>,
25}
26
27#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
28pub enum ERNProfile {
29    AudioAlbum,
30    AudioSingle,
31    Video,
32    Mixed,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
36pub struct MessageAuditTrail {
37    pub audit_trail_events: Vec<AuditTrailEvent>,
38    /// All XML attributes (standard and custom)
39    pub attributes: Option<AttributeMap>,
40    /// Extensions for audit trail
41    pub extensions: Option<Extensions>,
42    /// Comments associated with audit trail
43    pub comments: Option<Vec<Comment>>,
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
47pub struct AuditTrailEvent {
48    pub message_audit_trail_event_reference: String,
49    pub message_audit_trail_event_type: String,
50    pub date_time: chrono::DateTime<chrono::Utc>,
51    pub responsible_party_reference: Option<String>,
52    /// All XML attributes (standard and custom)
53    pub attributes: Option<AttributeMap>,
54    /// Extensions for individual audit trail events
55    pub extensions: Option<Extensions>,
56    /// Comments associated with this audit trail event
57    pub comments: Option<Vec<Comment>>,
58}
59
60impl ERNMessage {
61    pub fn to_build_request(&self) -> Self {
62        self.clone()
63    }
64}