use std::fmt;
use crate::model::{FilePayload, XmlDateTime};
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
pub enum CodeListDataType {
Number,
String,
Boolean,
Date,
Other(String),
}
impl CodeListDataType {
pub(crate) fn from_raw(raw: impl Into<String>) -> Self {
let raw = raw.into();
match raw.as_str() {
"Number" => Self::Number,
"String" => Self::String,
"Boolean" => Self::Boolean,
"Date" => Self::Date,
_ => Self::Other(raw),
}
}
pub fn as_str(&self) -> &str {
match self {
Self::Number => "Number",
Self::String => "String",
Self::Boolean => "Boolean",
Self::Date => "Date",
Self::Other(raw) => raw,
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub struct CodeListAttributeReference {
pub code_list_id: String,
pub attribute_id: String,
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum CodeListAttributeKind {
Plain(CodeListDataType),
Reference(CodeListAttributeReference),
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub struct CodeListAttribute {
pub id: String,
pub name: String,
pub kind: CodeListAttributeKind,
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub struct CodeListVersionInfo {
pub version: String,
pub valid_from: XmlDateTime,
pub valid_to: Option<XmlDateTime>,
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub struct CodeListInfo {
pub id: String,
pub name: String,
pub attributes: Vec<CodeListAttribute>,
pub latest_version: CodeListVersionInfo,
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub struct CodeListItemAttribute {
pub id: String,
pub value: String,
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub struct CodeListItem {
pub attributes: Vec<CodeListItemAttribute>,
pub invalidated: bool,
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub struct CodeList {
pub id: String,
pub name: String,
pub attributes: Vec<CodeListAttribute>,
pub version: CodeListVersionInfo,
pub items: Vec<CodeListItem>,
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub struct JvfVersion {
pub version: String,
pub valid_from: XmlDateTime,
pub valid_to: Option<XmlDateTime>,
pub description: String,
pub content: FilePayload,
}
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub struct IsDmvsCertificate {
pub usage_started_at: XmlDateTime,
pub valid_from: XmlDateTime,
pub valid_to: XmlDateTime,
pub certificate_pem: String,
}
impl fmt::Debug for IsDmvsCertificate {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter
.debug_struct("IsDmvsCertificate")
.field("usage_started_at", &self.usage_started_at)
.field("valid_from", &self.valid_from)
.field("valid_to", &self.valid_to)
.field("certificate_pem", &"[REDACTED]")
.finish()
}
}