Skip to main content

SqliteStorage

Struct SqliteStorage 

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

SQLite-backed storage for Stint.

Implementations§

Source§

impl SqliteStorage

Source

pub fn open(path: &Path) -> Result<Self, StorageError>

Opens or creates the database at the given path and runs migrations.

Source

pub fn open_existing(path: &Path) -> Result<Self, StorageError>

Opens an existing database without creating directories or running migrations.

Returns Err if the database file does not exist or cannot be opened. Intended for the shell hook fast path where the DB should already exist.

Source

pub fn open_in_memory() -> Result<Self, StorageError>

Opens an in-memory database for testing.

Source

pub fn default_path() -> PathBuf

Returns the XDG-compliant default database path.

Checks STINT_DB_PATH env var first, then falls back to ~/.local/share/stint/stint.db (or platform equivalent).

Trait Implementations§

Source§

impl Storage for SqliteStorage

Source§

fn create_project(&self, project: &Project) -> Result<(), StorageError>

Creates a new project. Returns error if name already exists.
Source§

fn get_project(&self, id: &ProjectId) -> Result<Option<Project>, StorageError>

Retrieves a project by its ID.
Source§

fn get_project_by_name( &self, name: &str, ) -> Result<Option<Project>, StorageError>

Retrieves a project by its name (case-insensitive).
Source§

fn get_project_by_path( &self, path: &Path, ) -> Result<Option<Project>, StorageError>

Finds the project whose registered path is the longest prefix of path.
Source§

fn list_projects( &self, status: Option<ProjectStatus>, ) -> Result<Vec<Project>, StorageError>

Lists all projects, optionally filtered by status.
Source§

fn update_project(&self, project: &Project) -> Result<(), StorageError>

Updates an existing project.
Source§

fn delete_project(&self, id: &ProjectId) -> Result<(), StorageError>

Deletes a project and all associated data.
Source§

fn create_entry(&self, entry: &TimeEntry) -> Result<(), StorageError>

Creates a new time entry.
Source§

fn get_entry(&self, id: &EntryId) -> Result<Option<TimeEntry>, StorageError>

Retrieves a time entry by its ID.
Source§

fn get_running_entry( &self, project_id: &ProjectId, ) -> Result<Option<TimeEntry>, StorageError>

Finds the currently running entry for a specific project.
Source§

fn get_running_hook_entry( &self, project_id: &ProjectId, ) -> Result<Option<TimeEntry>, StorageError>

Finds the currently running hook-sourced entry for a specific project.
Source§

fn get_any_running_entry(&self) -> Result<Option<TimeEntry>, StorageError>

Finds any currently running entry across all projects.
Source§

fn list_entries( &self, filter: &EntryFilter, ) -> Result<Vec<TimeEntry>, StorageError>

Lists entries matching the given filter.
Source§

fn get_last_entry(&self) -> Result<Option<TimeEntry>, StorageError>

Returns the most recent time entry.
Source§

fn update_entry(&self, entry: &TimeEntry) -> Result<(), StorageError>

Updates an existing time entry.
Source§

fn delete_entry(&self, id: &EntryId) -> Result<(), StorageError>

Deletes a time entry.
Source§

fn upsert_session(&self, session: &ShellSession) -> Result<(), StorageError>

Creates or updates a shell session record.
Source§

fn get_session( &self, id: &SessionId, ) -> Result<Option<ShellSession>, StorageError>

Retrieves a session by its ID.
Source§

fn get_session_by_pid( &self, pid: u32, ) -> Result<Option<ShellSession>, StorageError>

Finds an active session by shell PID.
Source§

fn end_session( &self, id: &SessionId, ended_at: OffsetDateTime, ) -> Result<(), StorageError>

Marks a session as ended.
Source§

fn count_active_sessions_for_project( &self, project_id: &ProjectId, exclude_session_id: &SessionId, ) -> Result<usize, StorageError>

Counts active sessions tracking a given project, excluding a specific session.
Source§

fn get_stale_sessions( &self, older_than: OffsetDateTime, ) -> Result<Vec<ShellSession>, StorageError>

Finds active sessions whose last heartbeat is older than the given time.
Source§

fn add_ignored_path(&self, path: &Path) -> Result<(), StorageError>

Adds a path to the ignore list for auto-discovery.
Source§

fn remove_ignored_path(&self, path: &Path) -> Result<bool, StorageError>

Removes a path from the ignore list.
Source§

fn is_path_ignored(&self, path: &Path) -> Result<bool, StorageError>

Checks if a path (or any of its ancestors) is in the ignore list.
Source§

fn list_ignored_paths(&self) -> Result<Vec<PathBuf>, StorageError>

Lists all ignored paths.

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V