#![allow(
clippy::doc_markdown,
clippy::doc_link_with_quotes,
clippy::tabs_in_doc_comments,
clippy::doc_lazy_continuation,
clippy::doc_overindented_list_items,
clippy::struct_excessive_bools,
clippy::struct_field_names,
clippy::module_inception,
clippy::large_enum_variant,
clippy::enum_variant_names,
reason = "inherent to faithful openEHR spec generation: verbatim spec prose in doc comments, and spec-owned class/variant/field names (a field name IS the normative BMM attribute name)"
)]
#![expect(
clippy::pub_use,
reason = "the generation preludes are this crate's public surface"
)]
#![recursion_limit = "512"]
pub mod prelude;
pub mod v1_1;
pub mod v1_2;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Generation {
V1_1,
#[default]
V1_2,
}
impl Generation {
#[must_use]
pub const fn spec_version(self) -> &'static str {
match self {
Self::V1_1 => "1.1.0",
Self::V1_2 => "1.2.0",
}
}
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::V1_1 => "v1_1",
Self::V1_2 => "v1_2",
}
}
}
impl std::fmt::Display for Generation {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GenerationParseError {
unrecognized: String,
}
impl std::fmt::Display for GenerationParseError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"unknown generation {:?} (valid: `v1_1`, `v1_2`)",
self.unrecognized
)
}
}
impl std::error::Error for GenerationParseError {}
impl std::str::FromStr for Generation {
type Err = GenerationParseError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"v1_1" => Ok(Self::V1_1),
"v1_2" => Ok(Self::V1_2),
other => Err(GenerationParseError {
unrecognized: other.to_owned(),
}),
}
}
}
mod json_serde;