Skip to main content

MemoryRepo

Struct MemoryRepo 

Source
pub struct MemoryRepo { /* private fields */ }
Expand description

Git-backed repository for persisting and syncing memory files.

Implementations§

Source§

impl MemoryRepo

Source

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).

Source

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.

Source

pub async fn delete_memory( self: &Arc<Self>, name: &str, scope: &Scope, ) -> Result<(), MemoryError>

Remove a memory’s file and commit the deletion.

Source

pub async fn read_memory( self: &Arc<Self>, name: &str, scope: &Scope, ) -> Result<Memory, MemoryError>

Read and parse a memory from disk.

Source

pub async fn list_memories( self: &Arc<Self>, scope: Option<&Scope>, ) -> Result<Vec<Memory>, MemoryError>

List all memories, optionally filtered by scope.

Source

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.

Source

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.

Source

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§

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,