#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Cardinality {
pub min: u32,
pub max: Max,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Max {
Bounded(u32),
Unbounded,
}
#[derive(Debug, PartialEq, Eq)]
pub struct Message {
pub id: &'static str,
pub url: &'static str,
pub code: &'static str,
pub event: &'static str,
pub structure: Option<&'static Structure>,
pub status: MessageStatus,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MessageStatus {
Active,
Withdrawn,
}
#[derive(Debug, PartialEq, Eq)]
pub struct LegacyMessage {
pub code: &'static str,
pub event: &'static str,
pub version: &'static str,
pub structure: &'static Structure,
}
#[derive(Debug, PartialEq, Eq)]
pub struct Structure {
pub id: &'static str,
pub url: Option<&'static str>,
pub version: &'static str,
pub withdrawn_as_of: Option<&'static str>,
pub nodes: &'static [Node],
}
#[derive(Debug, PartialEq, Eq)]
pub enum Node {
Segment(SegmentRef),
Group(Group),
Placeholder(Placeholder),
}
#[derive(Debug, PartialEq, Eq)]
pub struct SegmentRef {
pub id: &'static str,
pub position: u16,
pub segment: &'static Segment,
pub cardinality: Cardinality,
pub status: Option<SegmentStatus>,
}
#[derive(Debug, PartialEq, Eq)]
pub struct Group {
pub id: &'static str,
pub position: u16,
pub name: &'static str,
pub cardinality: Cardinality,
pub kind: GroupKind,
pub children: &'static [Node],
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum GroupKind {
Sequence,
Choice,
}
#[derive(Debug, PartialEq, Eq)]
pub struct Placeholder {
pub id: &'static str,
pub position: u16,
pub cardinality: Cardinality,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SegmentStatus {
A,
B,
D,
}
#[derive(Debug, PartialEq, Eq)]
pub struct Segment {
pub id: &'static str,
pub url: Option<&'static str>,
pub name: &'static str,
pub fields: &'static [Field],
}
#[derive(Debug, PartialEq, Eq)]
pub struct Field {
pub id: &'static str,
pub position: u16,
pub name: &'static str,
pub data_type: Option<DataTypeRef>,
pub cardinality: Cardinality,
pub optionality: Optionality,
pub length: Option<Length>,
pub conformance_length: Option<ConformanceLength>,
pub table: Option<Table>,
pub standards_status: Option<StandardsStatus>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DataTypeRef {
Defined(&'static DataType),
Undefined(&'static str),
Legacy(&'static LegacyDataType),
}
impl DataTypeRef {
#[must_use]
pub const fn code(&self) -> &'static str {
match self {
Self::Defined(data_type) => data_type.code,
Self::Legacy(data_type) => data_type.code,
Self::Undefined(code) => code,
}
}
}
#[derive(Debug, PartialEq, Eq)]
pub struct LegacyDataType {
pub code: &'static str,
pub version: &'static str,
pub name: &'static str,
pub base: Option<LegacyBase>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct LegacyBase {
pub code: &'static str,
pub table: Option<&'static str>,
}
#[derive(Debug, PartialEq, Eq)]
pub struct DataType {
pub code: &'static str,
pub url: &'static str,
pub name: &'static str,
pub components: &'static [Component],
}
#[derive(Debug, PartialEq, Eq)]
pub struct Component {
pub id: &'static str,
pub position: u16,
pub name: &'static str,
pub data_type: Option<&'static DataType>,
pub cardinality: Option<Cardinality>,
pub optionality: Optionality,
pub length: Option<Length>,
pub conformance_length: Option<ConformanceLength>,
pub table: Option<Table>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Optionality {
R,
Re,
O,
C,
Conditional {
first: ConditionalCode,
second: ConditionalCode,
},
X,
B,
W,
Na,
Unstated,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ConditionalCode {
R,
Re,
O,
X,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Length {
pub min: u32,
pub max: Option<u32>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ConformanceLength {
pub length: Option<u32>,
pub no_truncate: Option<bool>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Table {
pub id: &'static str,
pub value_set: &'static str,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StandardsStatus {
Deprecated,
Withdrawn,
}