Skip to main content

memnite_ingest/
source.rs

1use std::path::Path;
2
3use memnite_core::Scope;
4
5use crate::error::IngestError;
6
7/// The universal item every ingest source produces. memnite turns each into a
8/// `MemoryAdded`/`MemoryUpdated` event. (`Eq` is not derived: `Scope` is only
9/// `PartialEq`.)
10#[derive(Clone, Debug, PartialEq)]
11pub struct IngestedMemory {
12    /// Stable key WITHIN the source (e.g. "ubiquitous-language::Harness").
13    /// Combined with the source name it yields a deterministic memory id.
14    pub source_key: String,
15    pub title: String,
16    pub body: String,
17    pub mem_type: String,
18    pub topic_key: Option<String>,
19    pub scope: Scope,
20}
21
22/// The extension point. One external system = one `impl IngestSource`.
23pub trait IngestSource {
24    /// Stable source name; part of the deterministic memory id.
25    fn name(&self) -> &str;
26    /// Read and parse whatever lives under `root` into memories.
27    fn collect(&self, root: &Path) -> Result<Vec<IngestedMemory>, IngestError>;
28}
29
30/// Outcome of an `App::ingest` run.
31#[derive(Clone, Debug, Default, PartialEq, Eq)]
32pub struct IngestSummary {
33    pub added: usize,
34    pub updated: usize,
35    pub unchanged: usize,
36}