pub struct ContextDocsManager { /* private fields */ }Expand description
Manages context-document metadata and dependency edges inside a Lore workspace.
§Usage
let manager = ContextDocsManager::new(workspace_path);
manager.register("task-123.md", &[("status", "active")])?;
manager.add_dependency("task-123.md", "characters/hero.yaml")?;
let deps = manager.dependents_of("characters/hero.yaml")?;Implementations§
Source§impl ContextDocsManager
impl ContextDocsManager
Sourcepub fn new(workspace_root: &Path) -> Self
pub fn new(workspace_root: &Path) -> Self
Create a new manager.
The graph is not loaded from Lore until the first operation that requires it (lazy init).
Sourcepub fn persist(&self) -> Result<(), NapError>
pub fn persist(&self) -> Result<(), NapError>
Write the current in-memory graph back to Lore metadata.
This is a two-step process:
- Serialise nodes and edges to JSON.
- Write to
.lore/metadata/nap.context_docsand.lore/metadata/nap.context_depsvia the VCS.
Sourcepub fn register(
&self,
path: &str,
metadata: &[(&str, &str)],
) -> Result<(), NapError>
pub fn register( &self, path: &str, metadata: &[(&str, &str)], ) -> Result<(), NapError>
Register a document with its metadata.
If the document already exists, its metadata is merged with
the new entries (new keys overwrite old ones; existing keys not in
metadata are preserved).
Sourcepub fn unregister(&self, path: &str) -> Result<(), NapError>
pub fn unregister(&self, path: &str) -> Result<(), NapError>
Remove a document from the graph.
Also removes all dependency edges where this document is the target or a source.
Sourcepub fn all_documents(&self) -> Result<Vec<ContextDocument>, NapError>
pub fn all_documents(&self) -> Result<Vec<ContextDocument>, NapError>
Get all documents and their metadata as a list.
Sourcepub fn get_document(
&self,
path: &str,
) -> Result<Option<ContextDocument>, NapError>
pub fn get_document( &self, path: &str, ) -> Result<Option<ContextDocument>, NapError>
Get a specific document by path.
Sourcepub fn add_dependency(&self, source: &str, target: &str) -> Result<(), NapError>
pub fn add_dependency(&self, source: &str, target: &str) -> Result<(), NapError>
Declare that source depends on target.
This adds source to the adjacency list of target.
Both paths must be registered; registering is implicit if they are
not yet known (the graph auto-vivifies them with empty metadata).
Sourcepub fn remove_dependency(
&self,
source: &str,
target: &str,
) -> Result<(), NapError>
pub fn remove_dependency( &self, source: &str, target: &str, ) -> Result<(), NapError>
Remove a dependency edge.
Sourcepub fn dependents_of(&self, target: &str) -> Result<Vec<String>, NapError>
pub fn dependents_of(&self, target: &str) -> Result<Vec<String>, NapError>
Get the set of documents that directly depend on target.
Sourcepub fn dependencies_of(&self, source: &str) -> Result<Vec<String>, NapError>
pub fn dependencies_of(&self, source: &str) -> Result<Vec<String>, NapError>
Get the set of documents that source depends on.
This is a reverse lookup: we scan all edges for where source
appears as a dependent.
Sourcepub fn graph_as_json(&self) -> Result<String, NapError>
pub fn graph_as_json(&self) -> Result<String, NapError>
Get the full dependency graph as a JSON string (for debugging or context-graph assembly).
Auto Trait Implementations§
impl !Freeze for ContextDocsManager
impl RefUnwindSafe for ContextDocsManager
impl Send for ContextDocsManager
impl Sync for ContextDocsManager
impl Unpin for ContextDocsManager
impl UnsafeUnpin for ContextDocsManager
impl UnwindSafe for ContextDocsManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more