Skip to main content

owl_structural_model/
class_axiom.rs

1//! Checked construction for class axiom families.
2use crate::{Axiom, AxiomAnnotations, ClassExpression, Entity, OperandSet, StructuralModelError};
3use iri_rfc3987::Iri;
4impl<L, B> Axiom<L, B> {
5    /// Construct `Declaration` without axiom annotations.
6    #[must_use]
7    pub fn declaration(entity: Entity) -> Self {
8        Self::Declaration {
9            entity,
10            annotations: AxiomAnnotations::empty(),
11        }
12    }
13    /// Construct `SubClassOf` without axiom annotations.
14    #[must_use]
15    pub fn sub_class_of(
16        sub_class: ClassExpression<L, B>,
17        super_class: ClassExpression<L, B>,
18    ) -> Self {
19        Self::SubClassOf {
20            sub_class,
21            super_class,
22            annotations: AxiomAnnotations::empty(),
23        }
24    }
25    /// Construct `EquivalentClasses` without axiom annotations.
26    /// # Errors
27    /// Rejects fewer than the structural minimum number of source occurrences.
28    pub fn equivalent_classes(
29        classes: Vec<ClassExpression<L, B>>,
30    ) -> Result<Self, StructuralModelError> {
31        Ok(Self::EquivalentClasses {
32            classes: OperandSet::try_new(classes)?,
33            annotations: AxiomAnnotations::empty(),
34        })
35    }
36    /// Construct `DisjointClasses` without axiom annotations.
37    /// # Errors
38    /// Rejects fewer than the structural minimum number of source occurrences.
39    pub fn disjoint_classes(
40        classes: Vec<ClassExpression<L, B>>,
41    ) -> Result<Self, StructuralModelError> {
42        Ok(Self::DisjointClasses {
43            classes: OperandSet::try_new(classes)?,
44            annotations: AxiomAnnotations::empty(),
45        })
46    }
47    /// Construct `DisjointUnion` without axiom annotations.
48    /// # Errors
49    /// Rejects fewer than the structural minimum number of source occurrences.
50    pub fn disjoint_union(
51        class: Iri<String>,
52        classes: Vec<ClassExpression<L, B>>,
53    ) -> Result<Self, StructuralModelError> {
54        Ok(Self::DisjointUnion {
55            class,
56            classes: OperandSet::try_new(classes)?,
57            annotations: AxiomAnnotations::empty(),
58        })
59    }
60}