owl-structural-model 1.0.0

Typed OWL 2 structural values for Rust
Documentation
#![doc = include_str!("../README.md")]
#![forbid(unsafe_code)]

//! Typed OWL 2 structural values without an RDF-store dependency.

mod annotation;
mod axiom;
mod class_expression;
mod data_range;
mod entity;
mod error;
mod key;
mod ontology;
mod patch;
mod property_axiom;
mod property_chain;
mod property_schema;

pub use annotation::{Annotation, AnnotationSubject, AnnotationValue, AxiomAnnotations};
pub use axiom::Axiom;
pub use class_expression::{ClassExpression, ObjectPropertyExpression};
pub use data_range::{DataRange, FacetRestriction};
pub use entity::{Entity, EntityKind};
pub use error::StructuralModelError;
pub use key::KeyProperties;
pub use ontology::{OntologyId, OntologyIdentity};
pub use patch::{OntologyPatch, OntologyPatchOperation};
pub use property_chain::{ObjectPropertyChain, SubObjectPropertyExpression};
pub use rdf_structural_model::{BlankNodeId, Literal as OwlLiteral};

#[cfg(test)]
mod tests {
    use iri_rfc3987::Iri;

    use super::*;

    fn iri(value: &str) -> Iri<String> {
        Iri::parse(value).expect("test IRI is valid").into()
    }

    #[test]
    fn constructors_preserve_structural_shape() {
        let axiom: Axiom = Axiom::sub_class_of(
            ClassExpression::named(iri("https://example.org/Customer")),
            ClassExpression::named(iri("https://example.org/Party")),
        );

        assert!(matches!(axiom, Axiom::SubClassOf { .. }));
        assert_eq!(
            Entity::class(iri("https://example.org/Customer")).kind(),
            EntityKind::Class
        );
    }

    #[test]
    fn invalid_structural_values_fail_at_construction() {
        let error = ClassExpression::object_union_of(Vec::new()).unwrap_err();
        assert!(matches!(error, StructuralModelError::InvalidFormat { .. }));

        assert!(rdf_structural_model::LanguageTag::try_new("").is_err());
    }

    #[test]
    fn ontology_identity_rejects_version_without_name() {
        let error = OntologyId::try_new(None, Some(iri("https://example.org/v1"))).unwrap_err();
        assert!(matches!(error, StructuralModelError::InvalidFormat { .. }));
    }

    /// ```
    /// use iri_rfc3987::Iri;
    /// use owl_structural_model::{Axiom, ClassExpression};
    ///
    /// let parse = |value: &str| Iri::parse(value).expect("valid IRI").into();
    /// let axiom: Axiom = Axiom::sub_class_of(
    ///     ClassExpression::named(parse("https://example.org/Customer")),
    ///     ClassExpression::named(parse("https://example.org/Party")),
    /// );
    /// assert!(matches!(axiom, Axiom::SubClassOf { .. }));
    /// ```
    #[test]
    fn doctest_anchor() {}
}