pub struct SqliteStorage { /* private fields */ }Expand description
SQLite-backed storage for Stint.
Implementations§
Source§impl SqliteStorage
impl SqliteStorage
Sourcepub fn open(path: &Path) -> Result<Self, StorageError>
pub fn open(path: &Path) -> Result<Self, StorageError>
Opens or creates the database at the given path and runs migrations.
Sourcepub fn open_existing(path: &Path) -> Result<Self, StorageError>
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.
Sourcepub fn open_in_memory() -> Result<Self, StorageError>
pub fn open_in_memory() -> Result<Self, StorageError>
Opens an in-memory database for testing.
Sourcepub fn default_path() -> PathBuf
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
impl Storage for SqliteStorage
Source§fn create_project(&self, project: &Project) -> Result<(), StorageError>
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>
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>
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>
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>
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>
fn update_project(&self, project: &Project) -> Result<(), StorageError>
Updates an existing project.
Source§fn delete_project(&self, id: &ProjectId) -> Result<(), StorageError>
fn delete_project(&self, id: &ProjectId) -> Result<(), StorageError>
Deletes a project and all associated data.
Source§fn create_entry(&self, entry: &TimeEntry) -> Result<(), StorageError>
fn create_entry(&self, entry: &TimeEntry) -> Result<(), StorageError>
Creates a new time entry.
Source§fn get_entry(&self, id: &EntryId) -> Result<Option<TimeEntry>, StorageError>
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>
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>
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>
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>
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>
fn get_last_entry(&self) -> Result<Option<TimeEntry>, StorageError>
Returns the most recent time entry.
Source§fn update_entry(&self, entry: &TimeEntry) -> Result<(), StorageError>
fn update_entry(&self, entry: &TimeEntry) -> Result<(), StorageError>
Updates an existing time entry.
Source§fn delete_entry(&self, id: &EntryId) -> Result<(), StorageError>
fn delete_entry(&self, id: &EntryId) -> Result<(), StorageError>
Deletes a time entry.
Source§fn upsert_session(&self, session: &ShellSession) -> Result<(), StorageError>
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>
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>
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>
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>
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>
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>
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>
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>
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>
fn list_ignored_paths(&self) -> Result<Vec<PathBuf>, StorageError>
Lists all ignored paths.
Auto Trait Implementations§
impl !Freeze for SqliteStorage
impl !RefUnwindSafe for SqliteStorage
impl Send for SqliteStorage
impl !Sync for SqliteStorage
impl Unpin for SqliteStorage
impl UnsafeUnpin for SqliteStorage
impl !UnwindSafe for SqliteStorage
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