pub struct Store { /* private fields */ }Expand description
SQLite-backed durable state for vibesurfer.
Implementations§
Source§impl Store
impl Store
Sourcepub fn record_action(&mut self, ins: &ActionInsert) -> Result<i64>
pub fn record_action(&mut self, ins: &ActionInsert) -> Result<i64>
Insert one row into actions. Returns the autoincrement id.
Sourcepub fn lookup_idempotent(
&self,
page_id: &str,
before_token: &str,
args_hash: &str,
now_secs: i64,
ttl_secs: i64,
) -> Result<Option<Action>>
pub fn lookup_idempotent( &self, page_id: &str, before_token: &str, args_hash: &str, now_secs: i64, ttl_secs: i64, ) -> Result<Option<Action>>
Look up the most recent successful action whose
(page_id, before_token, args_hash) triple matches and whose
started_at is within ttl_secs of now_secs. The caller
supplies now_secs for testability; production calls
super::epoch_secs.
pub fn list_actions(&self, filter: &ActionFilter) -> Result<Vec<Action>>
Source§impl Store
impl Store
pub fn add_annotation( &mut self, id: &str, target: &AnnotationTarget, key: &str, value: Option<&str>, ) -> Result<Annotation>
pub fn list_annotations( &self, target: &AnnotationTarget, ) -> Result<Vec<Annotation>>
Source§impl Store
impl Store
Sourcepub fn save_auth(
&mut self,
name: &str,
key: &MasterKey,
plaintext: &[u8],
) -> Result<()>
pub fn save_auth( &mut self, name: &str, key: &MasterKey, plaintext: &[u8], ) -> Result<()>
Encrypt plaintext under key and store under name. Replaces
any existing blob with the same name.
Sourcepub fn load_auth(&mut self, name: &str, key: &MasterKey) -> Result<Vec<u8>>
pub fn load_auth(&mut self, name: &str, key: &MasterKey) -> Result<Vec<u8>>
Decrypt the named blob. Stamps last_used_at on success.
pub fn list_auth(&self) -> Result<Vec<AuthBlobMeta>>
pub fn delete_auth(&mut self, name: &str) -> Result<()>
Source§impl Store
impl Store
pub fn create_mark( &mut self, id: &str, session_id: &str, page_id: &str, name: &str, dom_path: &str, role: Option<&str>, content_excerpt: Option<&str>, ) -> Result<Mark>
pub fn get_mark(&self, session_id: &str, name: &str) -> Result<Option<Mark>>
pub fn list_marks(&self, session_id: &str) -> Result<Vec<Mark>>
pub fn delete_mark(&mut self, session_id: &str, name: &str) -> Result<()>
Source§impl Store
impl Store
pub fn create_page( &mut self, id: &str, session_id: &str, url: &str, ) -> Result<Page>
pub fn close_page(&mut self, id: &str) -> Result<()>
pub fn update_page_token( &mut self, id: &str, token: &str, dom_hash: &str, title: Option<&str>, ) -> Result<()>
pub fn get_page(&self, id: &str) -> Result<Option<Page>>
pub fn list_pages(&self, session_id: &str) -> Result<Vec<Page>>
Source§impl Store
impl Store
Sourcepub fn create_session(
&mut self,
id: &str,
policy_id: Option<&str>,
) -> Result<Session>
pub fn create_session( &mut self, id: &str, policy_id: Option<&str>, ) -> Result<Session>
Insert a new session row and return it.
Sourcepub fn close_session(&mut self, id: &str) -> Result<Session>
pub fn close_session(&mut self, id: &str) -> Result<Session>
Mark a session closed (and stamp closed_at). Returns the row.
pub fn get_session(&self, id: &str) -> Result<Option<Session>>
pub fn list_sessions(&self) -> Result<Vec<Session>>
Source§impl Store
impl Store
pub fn upsert_skill(&mut self, entry: &SkillEntry) -> Result<()>
pub fn get_skill(&self, name: &str) -> Result<Option<SkillEntry>>
pub fn list_skills(&self) -> Result<Vec<SkillEntry>>
Source§impl Store
impl Store
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Open the store at path, applying any not-yet-applied
migrations and configuring WAL mode and foreign keys.
Sourcepub fn open_in_memory() -> Result<Self>
pub fn open_in_memory() -> Result<Self>
Open an in-memory store (tests only — dropped when the handle goes out of scope).
Sourcepub fn open_read_only(path: impl AsRef<Path>) -> Result<Self>
pub fn open_read_only(path: impl AsRef<Path>) -> Result<Self>
Open path read-only, without running migrations. Use for
vs_log queries that should never block on a write lock.
Sourcepub fn conn(&self) -> &Connection
pub fn conn(&self) -> &Connection
Borrow the underlying connection. Per-table submodules use this
instead of self.conn to keep the field private.