pub struct RecordIndex { /* private fields */ }Expand description
The typed records of every session on the machine: {"version": 1, "records": [...]} in one document. Writes
read, change and replace the document while holding an exclusive lock on <path>.lock (file-backed), so two
sessions never lose each other’s records.
Implementations§
Source§impl RecordIndex
impl RecordIndex
pub fn in_memory() -> RecordIndex
Sourcepub fn file(path: impl Into<PathBuf>) -> RecordIndex
pub fn file(path: impl Into<PathBuf>) -> RecordIndex
The index file every session of an agent directory shares.
Sourcepub fn for_agent_dir(agent_dir: &Path) -> RecordIndex
pub fn for_agent_dir(agent_dir: &Path) -> RecordIndex
<agent dir>/memory/records.json.
Sourcepub fn entries(&self) -> Result<Vec<IndexEntry>, String>
pub fn entries(&self) -> Result<Vec<IndexEntry>, String>
Every indexed record, in the order they were first indexed.
Sourcepub fn entry(&self, id: &str) -> Result<Option<IndexEntry>, String>
pub fn entry(&self, id: &str) -> Result<Option<IndexEntry>, String>
The record with document id id.
Sourcepub fn by_key(
&self,
key: &str,
scope: &str,
filters: &Map<String, Value>,
) -> Result<Option<IndexEntry>, String>
pub fn by_key( &self, key: &str, scope: &str, filters: &Map<String, Value>, ) -> Result<Option<IndexEntry>, String>
The visible record holding key in scope.
Sourcepub fn upsert(&self, entry: IndexEntry) -> Result<(), String>
pub fn upsert(&self, entry: IndexEntry) -> Result<(), String>
Add entry, replacing the record with its id (it keeps its place).
pub fn remove(&self, id: &str) -> Result<(), String>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RecordIndex
impl !RefUnwindSafe for RecordIndex
impl !UnwindSafe for RecordIndex
impl Forget for RecordIndex
impl Move for RecordIndex
impl Send for RecordIndex
impl Sync for RecordIndex
impl Unpin for RecordIndex
impl UnsafeUnpin for RecordIndex
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
Mutably borrows from an owned value. Read more