Skip to main content

Session

Struct Session 

Source
pub struct Session<'db> { /* private fields */ }
Expand description

A scoped conversation session over a Mnemo database.

Created by Mnemo::session. Holds the database mutably until it is closed (or dropped), so all writes for the conversation flow through it.

Implementations§

Source§

impl<'db> Session<'db>

Source

pub fn id(&self) -> &str

This session’s unique id (a ULID string), stamped on every turn.

Source

pub fn agent(&self) -> &str

The agent this session belongs to.

Source

pub fn turn_ids(&self) -> &[Ulid]

Ids of the turns recorded so far, in order.

Source

pub fn turn_count(&self) -> usize

How many turns have been recorded.

Source

pub fn add_turn(&mut self, turn: Turn) -> Result<Ulid>

Record a conversation turn as a Working memory tagged with this session and agent. The turn’s role is kept in the memory’s metadata. Writes are staged; they reach disk on Session::close (or any later flush of the database).

Source

pub fn recall(&mut self, request: RecallRequest) -> Result<Vec<RecallResult>>

Retrieve memories for context injection, scoped to this session’s agent. The agent filter on request is overridden — a session always recalls within its own agent’s view (its private memories plus shared ones). All other request fields (type filter, weights, top-k) apply.

Source

pub fn close(self) -> Result<usize>

End the session, consolidating its working turns into episodic memory: each turn still typed Working is promoted to Episodic, the store of “what happened”. Returns the number of turns promoted; the database is flushed before returning.

Source

pub fn discard(self) -> Result<usize>

End the session, discarding its working turns instead of consolidating them — every turn this session recorded is deleted. Returns the number removed; the database is flushed before returning.

Auto Trait Implementations§

§

impl<'db> !UnwindSafe for Session<'db>

§

impl<'db> Freeze for Session<'db>

§

impl<'db> RefUnwindSafe for Session<'db>

§

impl<'db> Send for Session<'db>

§

impl<'db> Sync for Session<'db>

§

impl<'db> Unpin for Session<'db>

§

impl<'db> UnsafeUnpin for Session<'db>

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, 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> Same for T

Source§

type Output = T

Should always be Self
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