pub struct ProspectiveStore { /* private fields */ }Expand description
Storage and query engine for prospective memory (reminders)
Implementations§
Source§impl ProspectiveStore
impl ProspectiveStore
Sourcepub fn column_family_descriptors() -> Vec<ColumnFamilyDescriptor>
pub fn column_family_descriptors() -> Vec<ColumnFamilyDescriptor>
Return the column family descriptors needed by ProspectiveStore.
Call this when opening the shared DB so the CFs are registered.
Sourcepub fn new(db: Arc<DB>, storage_path: &Path) -> Result<Self>
pub fn new(db: Arc<DB>, storage_path: &Path) -> Result<Self>
Create a new prospective store backed by the given shared DB.
The DB must have been opened with the column families returned by
[column_family_descriptors()]. On first run after the migration,
data from the old separate tasks/ and index/ sub-DBs is copied
into the corresponding CFs and the old directories are renamed.
Sourcepub fn flush(&self) -> Result<()>
pub fn flush(&self) -> Result<()>
Flush all column families to disk (critical for graceful shutdown)
Sourcepub fn databases(&self) -> Vec<(&str, &Arc<DB>)>
pub fn databases(&self) -> Vec<(&str, &Arc<DB>)>
Get references to all RocksDB databases for backup
Sourcepub fn store(&self, task: &ProspectiveTask) -> Result<()>
pub fn store(&self, task: &ProspectiveTask) -> Result<()>
Store a new prospective task
Sourcepub fn get(
&self,
user_id: &str,
task_id: &ProspectiveTaskId,
) -> Result<Option<ProspectiveTask>>
pub fn get( &self, user_id: &str, task_id: &ProspectiveTaskId, ) -> Result<Option<ProspectiveTask>>
Get a task by ID
Sourcepub fn update(&self, task: &ProspectiveTask) -> Result<()>
pub fn update(&self, task: &ProspectiveTask) -> Result<()>
Update a task (e.g., mark as triggered/dismissed)
Atomic: reads old task, builds a single WriteBatch containing old-index deletes + new task write + new index writes, then commits once.
Sourcepub fn delete(&self, user_id: &str, task_id: &ProspectiveTaskId) -> Result<bool>
pub fn delete(&self, user_id: &str, task_id: &ProspectiveTaskId) -> Result<bool>
Delete a task (atomic: removes task + all indices in single WriteBatch)
Sourcepub fn list_for_user(
&self,
user_id: &str,
status_filter: Option<ProspectiveTaskStatus>,
) -> Result<Vec<ProspectiveTask>>
pub fn list_for_user( &self, user_id: &str, status_filter: Option<ProspectiveTaskStatus>, ) -> Result<Vec<ProspectiveTask>>
List all tasks for a user, optionally filtered by status
Sourcepub fn get_due_tasks(&self, user_id: &str) -> Result<Vec<ProspectiveTask>>
pub fn get_due_tasks(&self, user_id: &str) -> Result<Vec<ProspectiveTask>>
Get all due time-based tasks for a user
Returns tasks where:
- Trigger is time-based (AtTime or AfterDuration)
- Trigger time <= now
- Status is Pending
Sourcepub fn get_all_due_tasks(&self) -> Result<Vec<(String, ProspectiveTask)>>
pub fn get_all_due_tasks(&self) -> Result<Vec<(String, ProspectiveTask)>>
Scan ALL users for due reminders (used by active reminder scheduler).
Returns (user_id, task) pairs for all pending tasks whose due time has passed.
Leverages the zero-padded due:{timestamp}:{task_id} index for efficient scanning:
lexicographic order = chronological, so we stop at the first future timestamp.
Sourcepub fn check_context_triggers(
&self,
user_id: &str,
context: &str,
) -> Result<Vec<ProspectiveTask>>
pub fn check_context_triggers( &self, user_id: &str, context: &str, ) -> Result<Vec<ProspectiveTask>>
Check for context-triggered reminders based on text content (keyword match only)
Returns tasks where:
- Trigger is OnContext
- Any keyword matches the context text
- Status is Pending
For semantic matching, use check_context_triggers_semantic instead.
Sourcepub fn check_context_triggers_semantic<F>(
&self,
user_id: &str,
context: &str,
context_embedding: &[f32],
embed_fn: F,
) -> Result<Vec<(ProspectiveTask, f32)>>
pub fn check_context_triggers_semantic<F>( &self, user_id: &str, context: &str, context_embedding: &[f32], embed_fn: F, ) -> Result<Vec<(ProspectiveTask, f32)>>
Check for context-triggered reminders using both keyword AND semantic matching
Returns tasks that either:
- Have keyword matches in the context (score = 1.0), OR
- Have semantic similarity above their threshold
§Arguments
user_id- User to check reminders forcontext- Current context text (for keyword matching)context_embedding- Precomputed embedding of the contextembed_fn- Closure to compute embedding for task content
§Returns
Vector of (task, score) tuples sorted by score (highest first)
Sourcepub fn mark_triggered(
&self,
user_id: &str,
task_id: &ProspectiveTaskId,
) -> Result<bool>
pub fn mark_triggered( &self, user_id: &str, task_id: &ProspectiveTaskId, ) -> Result<bool>
Mark a task as triggered
Sourcepub fn mark_dismissed(
&self,
user_id: &str,
task_id: &ProspectiveTaskId,
) -> Result<bool>
pub fn mark_dismissed( &self, user_id: &str, task_id: &ProspectiveTaskId, ) -> Result<bool>
Mark a task as dismissed
Sourcepub fn pending_count(&self, user_id: &str) -> Result<usize>
pub fn pending_count(&self, user_id: &str) -> Result<usize>
Get count of pending tasks for a user
Sourcepub fn find_by_prefix(
&self,
user_id: &str,
id_prefix: &str,
) -> Result<Option<ProspectiveTask>>
pub fn find_by_prefix( &self, user_id: &str, id_prefix: &str, ) -> Result<Option<ProspectiveTask>>
Find a task by ID prefix (for short ID lookups)
Allows users to dismiss reminders using short IDs like “d8cdc580” instead of full UUIDs like “d8cdc580-bf96-403a-85c5-57098c7b1786”
Auto Trait Implementations§
impl Freeze for ProspectiveStore
impl RefUnwindSafe for ProspectiveStore
impl Send for ProspectiveStore
impl Sync for ProspectiveStore
impl Unpin for ProspectiveStore
impl UnsafeUnpin for ProspectiveStore
impl UnwindSafe for ProspectiveStore
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for 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