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 reasoner;
33mod serialize;
34
35pub use axiom::{Axiom, AxiomId};
36pub use entity::{EntityId, EntityKind, EntityRecord, EntityRegistry};
37pub use error::{Error, Result};
38pub use graph::{AxiomIndex, AxiomStore};
39pub use iri::{InternPool, IriId};
40pub use limits::Limits;
41pub use ontology::{Ontology, OntologyBuilder};
42pub use reasoner::{Profile, Reasoner, ReasonerBuilder, ReasonerConfig};
43
44#[cfg(test)]
45mod integration_tests {
46    use super::*;
47
48    #[test]
49    fn classify_returns_not_implemented() {
50        let ontology = Ontology::default();
51        let reasoner = Reasoner::builder()
52            .profile(Profile::El)
53            .build(ontology)
54            .expect("build");
55        assert_eq!(reasoner.classify().unwrap_err(), Error::NotImplemented);
56        assert_eq!(reasoner.ontology().entity_count(), 0);
57    }
58
59    #[test]
60    fn reasoner_rejects_invalid_parallelism() {
61        let ontology = Ontology::default();
62        let err = Reasoner::builder()
63            .config(ReasonerConfig {
64                parallelism: 0,
65                ..ReasonerConfig::default()
66            })
67            .build(ontology)
68            .expect_err("parallelism");
69        assert!(matches!(err, Error::Message(_)));
70    }
71}