Skip to main content

knowledge_base_crud/write/
mod.rs

1mod execution;
2mod references;
3pub mod statements;
4
5pub use references::{ReferenceDraft, ReferenceRegistrationOutcome, ReferenceRegistrationStatus, References};
6pub use statements::{ApplyStatementsOutcome, StatementBatch, StatementInput, StatementResult, StatementResultStatus};
7
8use crate::KnowledgeBaseRepository;
9
10/// Controls whether a mutation is validated only or written to disk.
11#[derive(Clone, Copy, Debug, Eq, PartialEq)]
12pub enum WriteMode {
13    Preview,
14    Commit,
15}
16
17/// State-changing repository operations.
18#[derive(Clone, Copy, Debug)]
19pub struct WriteRepository<'a> {
20    repository: &'a KnowledgeBaseRepository,
21}
22
23impl<'a> WriteRepository<'a> {
24    pub(crate) fn new(repository: &'a KnowledgeBaseRepository) -> Self {
25        Self { repository }
26    }
27    pub fn statements(&self) -> StatementMutations<'a> {
28        StatementMutations { repository: self.repository }
29    }
30    pub fn references(&self) -> References<'a> {
31        References::new(self.repository)
32    }
33}
34
35#[derive(Clone, Copy, Debug)]
36pub struct StatementMutations<'a> {
37    pub(crate) repository: &'a KnowledgeBaseRepository,
38}