pub struct DurableMemory { /* private fields */ }Expand description
Open memory store for one workspace, shared by parent and child runtimes.
Implementations§
Source§impl DurableMemory
impl DurableMemory
Sourcepub fn open(layout: MemoryLayout) -> Result<Arc<Self>, DurableMemoryError>
pub fn open(layout: MemoryLayout) -> Result<Arc<Self>, DurableMemoryError>
Creates both scopes and writes their initial indexes.
Sourcepub fn open_from_env(
workspace_root: &Path,
) -> Result<Arc<Self>, DurableMemoryError>
pub fn open_from_env( workspace_root: &Path, ) -> Result<Arc<Self>, DurableMemoryError>
Opens the store at the XDG data-home location for workspace_root.
Sourcepub fn layout(&self) -> &MemoryLayout
pub fn layout(&self) -> &MemoryLayout
Returns the resolved global and workspace directories.
Sourcepub fn instructions(&self) -> String
pub fn instructions(&self) -> String
Stable instructions for the provider prefix.
The injected index is separate and belongs in the dynamic segment.
Sourcepub fn render_context(&self) -> Result<String, DurableMemoryError>
pub fn render_context(&self) -> Result<String, DurableMemoryError>
Renders the global and workspace indexes for one session.
Callers freeze the returned string for the life of the runtime so later topic writes do not rewrite the provider prefix.
Sourcepub fn note_read(&self, path: &Path) -> Result<(), DurableMemoryError>
pub fn note_read(&self, path: &Path) -> Result<(), DurableMemoryError>
Records a successful read of a topic and snapshots its full bytes.
Observation files, the generated index, and paths outside memory are ignored. A snapshot failure is returned to the caller, which should keep the file read itself successful.
Sourcepub fn governs_path(&self, path: &Path) -> bool
pub fn governs_path(&self, path: &Path) -> bool
Returns whether path is inside a durable-memory scope.
Workspace write scope does not authorize these paths. Callers still use
Self::authorize_write for the topic and observation rules.
Allows a patch when path is outside memory or the memory write is valid.
Topic updates and deletes require a snapshot from Self::note_read
that still matches the current file. The snapshot is not refreshed by
the write, so the next edit must read the file again.
Sourcepub fn refresh_after_writes(
&self,
paths: &[PathBuf],
) -> Result<(), DurableMemoryError>
pub fn refresh_after_writes( &self, paths: &[PathBuf], ) -> Result<(), DurableMemoryError>
Rewrites indexes for scopes touched by a successful memory write.