Skip to main content

Db

Struct Db 

Source
pub struct Db {
    pub conn: Connection,
}

Fields§

§conn: Connection

Implementations§

Source§

impl Db

Source

pub fn open_read_only(path: &Path) -> Result<Db, StoreError>

Read-only open for reporting over OTHER repos’ databases (stats --all): no migration, no WAL side files, works on read-only caches, and never touches a DB that a live agent session is writing.

Source

pub fn open(path: &Path) -> Result<Db, StoreError>

Source

pub fn insert_run(&self, r: &RunRecord) -> Result<(), StoreError>

Source

pub fn get_run(&self, target: &str) -> Result<Option<RunRecord>, StoreError>

Resolve a run by exact id, then by unique short-id prefix (newest wins).

Source

pub fn count_prefix(&self, prefix: &str) -> Result<i64, StoreError>

How many runs share a short-id prefix (for ambiguity detection).

Source

pub fn latest_run( &self, repo_root: &str, ) -> Result<Option<RunRecord>, StoreError>

Source

pub fn find_comparable_prior( &self, repo_root: &str, cwd: &str, command_family: &str, command_key: &str, before_created_at: &str, ) -> Result<Option<RunRecord>, StoreError>

The most recent comparable prior run (spec §12, hybrid decision #3): matched on (repo_root, cwd, command_family, command_key). Git state is NOT part of the match.

Source

pub fn upsert_session_start(&self, s: &SessionRecord) -> Result<(), StoreError>

Source

pub fn accumulate_session_tokens( &self, session_id: &str, raw: i64, emitted: i64, saved: i64, ) -> Result<(), StoreError>

Source

pub fn mark_full_output_requested(&self, run_id: &str) -> Result<(), StoreError>

Source

pub fn runs_before( &self, repo_root: &str, cutoff: &str, ) -> Result<Vec<RunRecord>, StoreError>

Runs older than cutoff (RFC3339), for log-file cleanup.

Source

pub fn delete_runs_before( &self, repo_root: &str, cutoff: &str, ) -> Result<usize, StoreError>

Delete run rows older than cutoff. Returns the number deleted.

Source

pub fn aggregate_stats( &self, repo_root: Option<&str>, ) -> Result<StatsAgg, StoreError>

Aggregate run stats; repo_root: None aggregates the whole database.

Source

pub fn top_savings( &self, repo_root: Option<&str>, limit: Option<usize>, ) -> Result<Vec<(String, i64)>, StoreError>

Top-N (display, saved_tokens) grouped by command, most savings first. Top saving commands; limit: None returns them all (SQLite LIMIT -1).

Source

pub fn repo_roots(&self) -> Result<Vec<String>, StoreError>

Distinct repo roots recorded in this database (normally one per cache).

Source

pub fn session_count(&self, repo_root: &str) -> Result<i64, StoreError>

Source

pub fn latest_activity( &self, repo_root: &str, ) -> Result<Option<String>, StoreError>

Source§

impl Db

Source

pub fn end_session( &self, session_id: &str, ended_at: &str, ) -> Result<(), StoreError>

Mark a session ended (idempotent — only sets ended_at once).

Auto Trait Implementations§

§

impl !Freeze for Db

§

impl !RefUnwindSafe for Db

§

impl !Sync for Db

§

impl !UnwindSafe for Db

§

impl Send for Db

§

impl Unpin for Db

§

impl UnsafeUnpin for 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.