knowledge-base-crud 0.3.0

Filesystem CRUD operations for a file-based knowledge base
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::{Error, KnowledgeBaseRepository, filesystem};
use knowledge_base_models::EntityId;

#[derive(Clone, Copy, Debug)]
pub struct EntityContexts<'a> {
    repository: &'a KnowledgeBaseRepository,
}

impl<'a> EntityContexts<'a> {
    pub(crate) fn new(repository: &'a KnowledgeBaseRepository) -> Self {
        Self { repository }
    }

    pub fn read(&self, id: &EntityId) -> Result<String, Error> {
        filesystem::read(self.repository.root(), "entity_context", id.as_str(), "md")
    }
}