Skip to main content

ontologos_core/
lib.rs

1//! Core data model and reasoner API for OntoLogos.
2//!
3//! v0.1 provides an in-memory ontology representation with interned IRIs,
4//! typed entities, structured axioms, secondary indexes, and JSON v2 serialization.
5//! OWL file parsing is available in v0.2 via `ontologos-parser`.
6//!
7//! # Quick example
8//!
9//! ```
10//! use ontologos_core::{Error, Ontology};
11//!
12//! fn main() -> Result<(), Error> {
13//!     let ontology = Ontology::builder()
14//!         .class("http://example.org/Pizza")?
15//!         .class("http://example.org/Food")?
16//!         .subclass_of("http://example.org/Pizza", "http://example.org/Food")?
17//!         .build()?;
18//!     assert_eq!(ontology.axiom_count(), 1);
19//!     Ok(())
20//! }
21//! ```
22
23#![warn(missing_docs)]
24
25mod axiom;
26mod entity;
27mod error;
28mod graph;
29mod iri;
30mod limits;
31mod ontology;
32mod parse_meta;
33mod reasoner;
34mod serialize;
35
36pub use axiom::{Axiom, AxiomId};
37pub use entity::{EntityId, EntityKind, EntityRecord, EntityRegistry};
38pub use error::{Error, Result};
39pub use graph::{AxiomIndex, AxiomStore};
40pub use iri::{InternPool, IriId};
41pub use limits::Limits;
42pub use ontology::{Ontology, OntologyBuilder};
43pub use parse_meta::{OwlConstruct, ParseMeta};
44pub use reasoner::{Profile, Reasoner, ReasonerBuilder, ReasonerConfig};
45
46#[cfg(test)]
47mod integration_tests {
48    use super::*;
49
50    #[test]
51    fn classify_returns_not_implemented() {
52        let ontology = Ontology::default();
53        let mut reasoner = Reasoner::builder()
54            .profile(Profile::El)
55            .build(ontology)
56            .expect("build");
57        assert_eq!(reasoner.classify().unwrap_err(), Error::NotImplemented);
58        assert_eq!(reasoner.ontology().entity_count(), 0);
59    }
60
61    #[test]
62    fn reasoner_rejects_invalid_parallelism() {
63        let ontology = Ontology::default();
64        let err = Reasoner::builder()
65            .config(ReasonerConfig {
66                parallelism: 0,
67                ..ReasonerConfig::default()
68            })
69            .build(ontology)
70            .expect_err("parallelism");
71        assert!(matches!(err, Error::Message(_)));
72    }
73}