Skip to main content

knowledge_base_crud/
lib.rs

1mod entity;
2mod entity_context;
3mod entity_type;
4mod error;
5mod mutation;
6mod property;
7mod reference;
8mod resource;
9
10pub use entity::{
11    ApplyMode, ApplyStatementsOutcome, Entities, EntitiesPage, EntityFilter, EntityRelationship, EntityRelationshipsPage, RelatedEntity, RelationshipDirection, StatementBatch,
12    StatementInput, StatementResult, StatementResultStatus,
13};
14pub use entity_context::EntityContexts;
15pub use entity_type::EntityTypes;
16pub use error::Error;
17pub use property::Properties;
18pub use reference::References;
19
20use std::path::{Path, PathBuf};
21
22#[derive(Clone, Debug)]
23pub struct KnowledgeBase {
24    root: PathBuf,
25}
26
27impl KnowledgeBase {
28    pub fn new(root: impl Into<PathBuf>) -> Self {
29        Self { root: root.into() }
30    }
31
32    pub fn root(&self) -> &Path {
33        &self.root
34    }
35
36    pub fn entities(&self) -> Entities<'_> {
37        Entities::new(self)
38    }
39
40    pub fn entity_types(&self) -> EntityTypes<'_> {
41        EntityTypes::new(self)
42    }
43
44    pub fn properties(&self) -> Properties<'_> {
45        Properties::new(self)
46    }
47
48    pub fn references(&self) -> References<'_> {
49        References::new(self)
50    }
51
52    pub fn entity_contexts(&self) -> EntityContexts<'_> {
53        EntityContexts::new(self)
54    }
55}