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§
Sourcefn 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.
Sourcefn 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.
Sourcefn 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).
Sourcefn 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.
Sourcefn 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.
Sourcefn update_project(&self, project: &Project) -> Result<(), StorageError>
fn update_project(&self, project: &Project) -> Result<(), StorageError>
Updates an existing project.
Sourcefn delete_project(&self, id: &ProjectId) -> Result<(), StorageError>
fn delete_project(&self, id: &ProjectId) -> Result<(), StorageError>
Deletes a project and all associated data.
Sourcefn create_entry(&self, entry: &TimeEntry) -> Result<(), StorageError>
fn create_entry(&self, entry: &TimeEntry) -> Result<(), StorageError>
Creates a new time entry.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn get_last_entry(&self) -> Result<Option<TimeEntry>, StorageError>
fn get_last_entry(&self) -> Result<Option<TimeEntry>, StorageError>
Returns the most recent time entry.
Sourcefn update_entry(&self, entry: &TimeEntry) -> Result<(), StorageError>
fn update_entry(&self, entry: &TimeEntry) -> Result<(), StorageError>
Updates an existing time entry.
Sourcefn delete_entry(&self, id: &EntryId) -> Result<(), StorageError>
fn delete_entry(&self, id: &EntryId) -> Result<(), StorageError>
Deletes a time entry.
Sourcefn upsert_session(&self, session: &ShellSession) -> Result<(), StorageError>
fn upsert_session(&self, session: &ShellSession) -> Result<(), StorageError>
Creates or updates a shell session record.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn list_ignored_paths(&self) -> Result<Vec<PathBuf>, StorageError>
fn list_ignored_paths(&self) -> Result<Vec<PathBuf>, StorageError>
Lists all ignored paths.