Skip to main content

Storage

Trait Storage 

Source
pub trait Storage {
Show 26 methods // Required methods fn create_project(&self, project: &Project) -> Result<(), StorageError>; fn get_project( &self, id: &ProjectId, ) -> Result<Option<Project>, StorageError>; fn get_project_by_name( &self, name: &str, ) -> Result<Option<Project>, StorageError>; fn get_project_by_path( &self, path: &Path, ) -> Result<Option<Project>, StorageError>; fn list_projects( &self, status: Option<ProjectStatus>, ) -> Result<Vec<Project>, StorageError>; fn update_project(&self, project: &Project) -> Result<(), StorageError>; fn delete_project(&self, id: &ProjectId) -> Result<(), StorageError>; fn create_entry(&self, entry: &TimeEntry) -> Result<(), StorageError>; fn get_entry(&self, id: &EntryId) -> Result<Option<TimeEntry>, StorageError>; fn get_running_entry( &self, project_id: &ProjectId, ) -> Result<Option<TimeEntry>, StorageError>; fn get_running_hook_entry( &self, project_id: &ProjectId, ) -> Result<Option<TimeEntry>, StorageError>; fn get_any_running_entry(&self) -> Result<Option<TimeEntry>, StorageError>; fn list_entries( &self, filter: &EntryFilter, ) -> Result<Vec<TimeEntry>, StorageError>; fn get_last_entry(&self) -> Result<Option<TimeEntry>, StorageError>; fn update_entry(&self, entry: &TimeEntry) -> Result<(), StorageError>; fn delete_entry(&self, id: &EntryId) -> Result<(), StorageError>; fn upsert_session(&self, session: &ShellSession) -> Result<(), StorageError>; fn get_session( &self, id: &SessionId, ) -> Result<Option<ShellSession>, StorageError>; fn get_session_by_pid( &self, pid: u32, ) -> Result<Option<ShellSession>, StorageError>; fn end_session( &self, id: &SessionId, ended_at: OffsetDateTime, ) -> Result<(), StorageError>; fn count_active_sessions_for_project( &self, project_id: &ProjectId, exclude_session_id: &SessionId, ) -> Result<usize, StorageError>; fn get_stale_sessions( &self, older_than: OffsetDateTime, ) -> Result<Vec<ShellSession>, StorageError>; fn add_ignored_path(&self, path: &Path) -> Result<(), StorageError>; fn remove_ignored_path(&self, path: &Path) -> Result<bool, StorageError>; fn is_path_ignored(&self, path: &Path) -> Result<bool, StorageError>; fn list_ignored_paths(&self) -> Result<Vec<PathBuf>, StorageError>;
}
Expand description

Pluggable storage backend for Stint.

Required Methods§

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.

Implementors§