pub struct MemoryRepo { /* private fields */ }Expand description
Git-backed repository for persisting and syncing memory files.
Implementations§
Source§impl MemoryRepo
impl MemoryRepo
Sourcepub fn init_or_open(
path: &Path,
remote_url: Option<&str>,
) -> Result<Self, MemoryError>
pub fn init_or_open( path: &Path, remote_url: Option<&str>, ) -> Result<Self, MemoryError>
Open an existing git repo at path, or initialise a new one.
If remote_url is provided, ensures an origin remote exists pointing
at that URL (creating or updating it as necessary).
Sourcepub async fn save_memory(
self: &Arc<Self>,
memory: &Memory,
) -> Result<(), MemoryError>
pub async fn save_memory( self: &Arc<Self>, memory: &Memory, ) -> Result<(), MemoryError>
Write the memory file to disk, then git add + git commit.
All blocking work (mutex lock + fs ops + git2 ops) is performed inside
tokio::task::spawn_blocking so the async executor is not stalled.
Sourcepub async fn delete_memory(
self: &Arc<Self>,
name: &str,
scope: &Scope,
) -> Result<(), MemoryError>
pub async fn delete_memory( self: &Arc<Self>, name: &str, scope: &Scope, ) -> Result<(), MemoryError>
Remove a memory’s file and commit the deletion.
Sourcepub async fn read_memory(
self: &Arc<Self>,
name: &str,
scope: &Scope,
) -> Result<Memory, MemoryError>
pub async fn read_memory( self: &Arc<Self>, name: &str, scope: &Scope, ) -> Result<Memory, MemoryError>
Read and parse a memory from disk.
Sourcepub async fn list_memories(
self: &Arc<Self>,
scope: Option<&Scope>,
) -> Result<Vec<Memory>, MemoryError>
pub async fn list_memories( self: &Arc<Self>, scope: Option<&Scope>, ) -> Result<Vec<Memory>, MemoryError>
List all memories, optionally filtered by scope.
Sourcepub async fn push(
self: &Arc<Self>,
auth: &AuthProvider,
branch: &str,
) -> Result<(), MemoryError>
pub async fn push( self: &Arc<Self>, auth: &AuthProvider, branch: &str, ) -> Result<(), MemoryError>
Push local commits to origin/<branch>.
If no origin remote is configured the call is a no-op (local-only
mode). Auth failures are propagated as MemoryError::Auth.
Sourcepub async fn pull(
self: &Arc<Self>,
auth: &AuthProvider,
branch: &str,
) -> Result<PullResult, MemoryError>
pub async fn pull( self: &Arc<Self>, auth: &AuthProvider, branch: &str, ) -> Result<PullResult, MemoryError>
Pull from origin/<branch> and merge into the current HEAD.
Uses a recency-based auto-resolution strategy for conflicts: the version
with the more recent updated_at frontmatter timestamp wins. If
timestamps are equal or unparseable, the local version is kept.
Sourcepub fn diff_changed_memories(
&self,
old_oid: [u8; 20],
new_oid: [u8; 20],
) -> Result<ChangedMemories, MemoryError>
pub fn diff_changed_memories( &self, old_oid: [u8; 20], new_oid: [u8; 20], ) -> Result<ChangedMemories, MemoryError>
Diff two commits and return the memory files that changed.
Only .md files under global/ or projects/ are considered.
Added/modified files go into upserted; deleted files go into removed.
Qualified names are returned without the .md suffix (e.g. "global/foo").
Must be called from within spawn_blocking since it uses git2.
Trait Implementations§
impl Send for MemoryRepo
impl Sync for MemoryRepo
Auto Trait Implementations§
impl !Freeze for MemoryRepo
impl RefUnwindSafe for MemoryRepo
impl Unpin for MemoryRepo
impl UnsafeUnpin for MemoryRepo
impl UnwindSafe for MemoryRepo
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
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