openbim_loin/lib.rs
1//! `openbim-loin` — ISO 7817-3 / EN 17412-3 Level of Information Need.
2//!
3//! # What this is
4//!
5//! A machine-readable statement of *how much* information is required about
6//! which objects, for a given purpose, at a given milestone, between a given
7//! pair of actors: geometric detail, alphanumeric properties, and
8//! documentation.
9//!
10//! EN 17412-1 defines the concepts in prose; part 3 is the exchange format.
11//! Only part 3 is implementable, and it is what this crate targets.
12//!
13//! # Relationship to ISO 23387
14//!
15//! The LOIN schema imports the ISO 23387 namespace for its property vocabulary.
16//! This crate therefore uses and re-exports `openbim-dt` contracts for GUIDs,
17//! multilingual text, references, concept inheritance, and embedded property,
18//! quantity, group, document, template, unit, and dimension content.
19//!
20//! # 🚨 The namespace is not final
21//!
22//! The draft schema carries, in a comment on line 2:
23//!
24//! > `Final LOIN Namespace will be specified after the review process`
25//!
26//! and declares `https://iso.org/2024/LOIN`, while an earlier draft declared
27//! `https://iso.org/2022/LOIN`. Namespace migration is therefore a
28//! *first-class* concern here, not an afterthought: reading must accept known
29//! historical namespaces, and writing must target one explicitly rather than
30//! defaulting to whatever was parsed.
31//!
32//! # Status
33//!
34//! The DT-backed domain boundary is implemented. XML reading, writing,
35//! namespace migration, and ISO schema validation are not yet implemented.
36//!
37//! The ISO XSD is **not vendored**. Both the ISO/CEN originals and the public
38//! committee drafts are unlicensed for redistribution, and the schema is a
39//! moving target; it is referenced out of tree instead.
40
41#![forbid(unsafe_code)]
42
43mod model;
44
45pub use model::{
46 Actor, AlphanumericalInformation, DatumRegistryReference, Detail, DocumentFormat,
47 Documentation, GeometricalInformation, InformationDeliveryMilestone, Prerequisites, Purpose,
48 RequiredDocument, Specification, SpecificationPerObjectType, ThresholdDimension,
49};
50/// Exact ISO 23387 contract version consumed by this LOIN release.
51pub use openbim_dt as dt;
52
53/// The namespace declared by the ISO 7817-3 draft schema (2024).
54pub const NAMESPACE_2024: &str = "https://iso.org/2024/LOIN";
55
56/// The namespace declared by the earlier EN 17412-3 committee draft (2022).
57///
58/// Retained because documents using it exist. Reading should accept it;
59/// writing should not emit it.
60pub const NAMESPACE_2022: &str = "https://iso.org/2022/LOIN";
61
62/// Namespaces this crate recognises as LOIN, newest first.
63///
64/// Ordered so that a reader trying candidates in sequence prefers the current
65/// one, and so that adding the final published namespace is a one-line change
66/// at the front of the list.
67pub const KNOWN_NAMESPACES: &[&str] = &[NAMESPACE_2024, NAMESPACE_2022];
68
69/// Whether a namespace URI is a LOIN namespace this crate knows.
70///
71/// ```
72/// use openbim_loin::{is_known_namespace, NAMESPACE_2024};
73/// assert!(is_known_namespace(NAMESPACE_2024));
74/// assert!(!is_known_namespace("https://example.invalid/LOIN"));
75/// ```
76#[must_use]
77pub fn is_known_namespace(ns: &str) -> bool {
78 KNOWN_NAMESPACES.contains(&ns)
79}
80
81#[cfg(test)]
82mod tests {
83 use super::*;
84
85 #[test]
86 fn both_draft_namespaces_are_recognised() {
87 assert!(is_known_namespace(NAMESPACE_2024));
88 assert!(is_known_namespace(NAMESPACE_2022));
89 }
90
91 #[test]
92 fn unknown_namespace_is_rejected() {
93 assert!(!is_known_namespace(""));
94 assert!(!is_known_namespace("https://iso.org/2099/LOIN"));
95 }
96
97 #[test]
98 fn current_namespace_is_preferred_first() {
99 assert_eq!(KNOWN_NAMESPACES.first(), Some(&NAMESPACE_2024));
100 }
101}