Skip to main content

InMemory

Struct InMemory 

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

In-memory store backed by Mutex<Vec<(String, String)>>.

Implementations§

Source§

impl InMemory

Source

pub fn new() -> InMemory

Create an empty store.

Source

pub fn with_entries( entries: impl IntoIterator<Item = (String, String)>, ) -> InMemory

Create a store pre-populated with entries.

Trait Implementations§

Source§

impl Debug for InMemory

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for InMemory

Source§

fn default() -> InMemory

Returns the “default value” for a type. Read more
Source§

impl Memory for InMemory

Source§

fn get(&self, key: &str) -> Option<String>

Get the value for a key (owned).
Source§

fn entries(&self) -> Vec<(String, String)>

Get all key-value pairs (owned).
Source§

fn set( &self, key: impl Into<String>, value: impl Into<String>, ) -> Option<String>

Set (upsert) a key-value pair. Returns the previous value if the key existed.
Source§

fn remove(&self, key: &str) -> Option<String>

Remove a key. Returns the removed value if it existed.
Source§

fn compile(&self) -> String

Compile all entries into a string for system prompt injection.
Source§

fn store( &self, key: impl Into<String> + Send, value: impl Into<String> + Send, ) -> impl Future<Output = Result<(), Error>> + Send

Store a key-value pair (async). Default delegates to set.
Source§

fn recall( &self, _query: &str, _options: RecallOptions, ) -> impl Future<Output = Result<Vec<MemoryEntry>, Error>> + Send

Search for relevant entries (async). Default returns empty.
Source§

fn compile_relevant(&self, _query: &str) -> impl Future<Output = String> + Send

Compile relevant entries for a query (async). Default delegates to compile.

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