openehr-lang 0.0.128

openEHR LANG BMM/P_BMM object model, generated from BMM: generations v1_0 (LANG 1.0.0) and v1_1 (LANG 1.1.0, current; the stable BMM v2.x unit beside the paused BMM3 unit), plus hand-written ODIN/BEL/EL readers
Documentation
// @generated by openehr-codegen — DO NOT EDIT.
// SPDX-FileCopyrightText: Cadasto B.V.
// SPDX-FileCopyrightText: openEHR Foundation
// SPDX-License-Identifier: Apache-2.0
//! openEHR LANG, generated from the BMM meta-model: one generation per component version. `v1_1` (the 1.1.0 development line, the current generation) carries the version's published specification units side by side — the STABLE, tool-implemented BMM v2.x model (`bmm`, its `bmm_persistence` P_BMM form, the `beom` BEL expression model; on the prelude) and the PAUSED BMM3 model (`bmm3`, full-path only) — plus the hand-written ODIN/BEL/EL readers and the shared lexer for that version's notations. The generator's own BMM reader lives in openehr-codegen (tooling, not spec).
//!
//! The type files are generated; hand-written spec behaviour
//! lives in sibling `*_impl.rs` files.

#![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)"
)]
// The generation preludes ARE this crate's public surface: the crate prelude re-exports the current generation, and each generation module re-exports its own types. That is the design (codegen.md), and it is the one place `clippy::pub_use` is satisfied by an exception rather than by removal. `expect` rather than `allow`: if a crate ever stops re-exporting, the exception self-reports instead of outliving its reason.
#![expect(
    clippy::pub_use,
    reason = "the generation preludes are this crate's public surface"
)]
// A vendored BMM model is a deep, mutually-recursive type graph (the LANG // BMM-3 expression/statement families reach several hundred levels), so // auto-trait inference — `Send`/`Sync`/`RefUnwindSafe`, which rustdoc // evaluates for every item — overflows the default limit of 128. Raising // the limit is exactly what rustc prescribes for that overflow // (<https://doc.rust-lang.org/reference/attributes/limits.html>); it // changes no emitted type.
#![recursion_limit = "512"]

pub mod prelude;
pub mod v1_0;
pub mod v1_1;

/// The BMM generations this crate emits, one variant per version module,
/// oldest first.
///
/// Generated from the openehr-codegen composition table — the single
/// authority for which generations exist. [`std::fmt::Display`] and
/// [`std::str::FromStr`] round-trip the generation-module name (`"v1_0"`). `Generation::default()` is the crate's CURRENT generation — the
/// one `crate::prelude` re-exports (the composition table's `current`
/// marker, via the std `#[default]` variant attribute).
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Generation {
    /// The `v1_0` generation — openEHR specification version 1.0.0.
    V1_0,
    /// The `v1_1` generation — openEHR specification version 1.1.0.
    #[default]
    V1_1,
}

impl Generation {
    /// Returns the openEHR specification version this generation implements.
    #[must_use]
    pub const fn spec_version(self) -> &'static str {
        match self {
            Self::V1_0 => "1.0.0",
            Self::V1_1 => "1.1.0",
        }
    }

    /// Returns the generation token — the version-module name
    /// (`"v1_1"`), which is also the [`std::fmt::Display`] and
    /// [`std::str::FromStr`] form.
    #[must_use]
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::V1_0 => "v1_0",
            Self::V1_1 => "v1_1",
        }
    }
}

impl std::fmt::Display for Generation {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

/// Error returned when parsing a [`Generation`] from an unknown token.
///
/// The valid tokens are the generation-module names (`v1_0`, `v1_1`).
#[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_0`, `v1_1`)",
            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_0" => Ok(Self::V1_0),
            "v1_1" => Ok(Self::V1_1),
            other => Err(GenerationParseError {
                unrecognized: other.to_owned(),
            }),
        }
    }
}

// hand-written modules (spec behaviour), auto-declared:
pub mod nesting;

// canonical-JSON `serde` impls (openehr-codegen -- emit-json), auto-declared:
mod json_serde;