owl_structural_model/
lib.rs1#![doc = include_str!("../README.md")]
2#![forbid(unsafe_code)]
3
4mod annotation;
7mod axiom;
8mod class_expression;
9mod entity;
10mod error;
11mod literal;
12mod ontology;
13mod patch;
14
15pub use annotation::{Annotation, AnnotationSubject, AnnotationValue, AxiomAnnotations};
16pub use axiom::Axiom;
17pub use class_expression::{ClassExpression, ObjectPropertyExpression};
18pub use entity::{Entity, EntityKind};
19pub use error::StructuralModelError;
20pub use literal::OwlLiteral;
21pub use ontology::{OntologyId, OntologyIdentity};
22pub use patch::{OntologyPatch, OntologyPatchOperation};
23
24#[cfg(test)]
25mod tests {
26 use iri_rfc3987::Iri;
27
28 use super::*;
29
30 fn iri(value: &str) -> Iri<String> {
31 Iri::parse(value).expect("test IRI is valid").into()
32 }
33
34 #[test]
35 fn constructors_preserve_structural_shape() {
36 let axiom = Axiom::sub_class_of(
37 ClassExpression::named(iri("https://example.org/Customer")),
38 ClassExpression::named(iri("https://example.org/Party")),
39 );
40
41 assert!(matches!(axiom, Axiom::SubClassOf { .. }));
42 assert_eq!(
43 Entity::class(iri("https://example.org/Customer")).kind(),
44 EntityKind::Class
45 );
46 }
47
48 #[test]
49 fn invalid_structural_values_fail_at_construction() {
50 let error = ClassExpression::object_union_of(Vec::new()).unwrap_err();
51 assert!(matches!(error, StructuralModelError::InvalidFormat { .. }));
52
53 let error = OwlLiteral::language_tagged("hello", "").unwrap_err();
54 assert!(matches!(error, StructuralModelError::Empty { .. }));
55 }
56
57 #[test]
58 fn ontology_identity_rejects_version_without_name() {
59 let error = OntologyId::try_new(None, Some(iri("https://example.org/v1"))).unwrap_err();
60 assert!(matches!(error, StructuralModelError::InvalidFormat { .. }));
61 }
62
63 #[test]
75 fn doctest_anchor() {}
76}