1use std::fmt;
2
3use crate::model::{FilePayload, XmlDateTime};
4
5#[derive(Clone, Debug, Eq, Hash, PartialEq)]
7#[non_exhaustive]
8pub enum CodeListDataType {
9 Number,
11 String,
13 Boolean,
15 Date,
17 Other(String),
19}
20
21impl CodeListDataType {
22 pub(crate) fn from_raw(raw: impl Into<String>) -> Self {
23 let raw = raw.into();
24 match raw.as_str() {
25 "Number" => Self::Number,
26 "String" => Self::String,
27 "Boolean" => Self::Boolean,
28 "Date" => Self::Date,
29 _ => Self::Other(raw),
30 }
31 }
32
33 pub fn as_str(&self) -> &str {
35 match self {
36 Self::Number => "Number",
37 Self::String => "String",
38 Self::Boolean => "Boolean",
39 Self::Date => "Date",
40 Self::Other(raw) => raw,
41 }
42 }
43}
44
45#[derive(Clone, Debug, Eq, PartialEq)]
47#[non_exhaustive]
48pub struct CodeListAttributeReference {
49 pub code_list_id: String,
51 pub attribute_id: String,
53}
54
55#[derive(Clone, Debug, Eq, PartialEq)]
57#[non_exhaustive]
58pub enum CodeListAttributeKind {
59 Plain(CodeListDataType),
61 Reference(CodeListAttributeReference),
63}
64
65#[derive(Clone, Debug, Eq, PartialEq)]
67#[non_exhaustive]
68pub struct CodeListAttribute {
69 pub id: String,
71 pub name: String,
73 pub kind: CodeListAttributeKind,
75}
76
77#[derive(Clone, Debug, Eq, PartialEq)]
79#[non_exhaustive]
80pub struct CodeListVersionInfo {
81 pub version: String,
83 pub valid_from: XmlDateTime,
85 pub valid_to: Option<XmlDateTime>,
87}
88
89#[derive(Clone, Debug, Eq, PartialEq)]
91#[non_exhaustive]
92pub struct CodeListInfo {
93 pub id: String,
95 pub name: String,
97 pub attributes: Vec<CodeListAttribute>,
99 pub latest_version: CodeListVersionInfo,
101}
102
103#[derive(Clone, Debug, Eq, PartialEq)]
105#[non_exhaustive]
106pub struct CodeListItemAttribute {
107 pub id: String,
109 pub value: String,
111}
112
113#[derive(Clone, Debug, Eq, PartialEq)]
115#[non_exhaustive]
116pub struct CodeListItem {
117 pub attributes: Vec<CodeListItemAttribute>,
119 pub invalidated: bool,
121}
122
123#[derive(Clone, Debug, Eq, PartialEq)]
125#[non_exhaustive]
126pub struct CodeList {
127 pub id: String,
129 pub name: String,
131 pub attributes: Vec<CodeListAttribute>,
133 pub version: CodeListVersionInfo,
135 pub items: Vec<CodeListItem>,
137}
138
139#[derive(Clone, Debug, Eq, PartialEq)]
141#[non_exhaustive]
142pub struct JvfVersion {
143 pub version: String,
145 pub valid_from: XmlDateTime,
147 pub valid_to: Option<XmlDateTime>,
149 pub description: String,
151 pub content: FilePayload,
153}
154
155#[derive(Clone, Eq, PartialEq)]
158#[non_exhaustive]
159pub struct IsDmvsCertificate {
160 pub usage_started_at: XmlDateTime,
162 pub valid_from: XmlDateTime,
164 pub valid_to: XmlDateTime,
166 pub certificate_pem: String,
168}
169
170impl fmt::Debug for IsDmvsCertificate {
171 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
172 formatter
173 .debug_struct("IsDmvsCertificate")
174 .field("usage_started_at", &self.usage_started_at)
175 .field("valid_from", &self.valid_from)
176 .field("valid_to", &self.valid_to)
177 .field("certificate_pem", &"[REDACTED]")
178 .finish()
179 }
180}