pub struct StintService<S: Storage> { /* private fields */ }Expand description
High-level operations for Stint, wrapping a storage backend.
Implementations§
Source§impl<S: Storage> StintService<S>
impl<S: Storage> StintService<S>
Sourcepub fn start_timer(
&self,
project_name: &str,
) -> Result<(TimeEntry, Project), StintError>
pub fn start_timer( &self, project_name: &str, ) -> Result<(TimeEntry, Project), StintError>
Starts a timer for the named project.
Fails if a timer is already running or the project is not found/archived.
Sourcepub fn stop_timer(&self) -> Result<(TimeEntry, Project), StintError>
pub fn stop_timer(&self) -> Result<(TimeEntry, Project), StintError>
Stops the currently running timer.
Fails if no timer is running.
Sourcepub fn add_time(
&self,
project_name: &str,
duration_secs: i64,
date: Option<OffsetDateTime>,
notes: Option<&str>,
) -> Result<(TimeEntry, Project), StintError>
pub fn add_time( &self, project_name: &str, duration_secs: i64, date: Option<OffsetDateTime>, notes: Option<&str>, ) -> Result<(TimeEntry, Project), StintError>
Adds a completed time entry retroactively.
If no date is provided, uses today. The entry is created with source: Added.
Sourcepub fn get_status(&self) -> Result<Option<(TimeEntry, Project)>, StintError>
pub fn get_status(&self) -> Result<Option<(TimeEntry, Project)>, StintError>
Returns the currently running timer and its project, if any.
Sourcepub fn archive_project(&self, name: &str) -> Result<Project, StintError>
pub fn archive_project(&self, name: &str) -> Result<Project, StintError>
Archives a project, hiding it from default listings.
Stops any running timer for the project first.
Sourcepub fn delete_project(&self, name: &str) -> Result<String, StintError>
pub fn delete_project(&self, name: &str) -> Result<String, StintError>
Deletes a project and all its entries.
Sourcepub fn get_entries(
&self,
filter: &EntryFilter,
) -> Result<Vec<(TimeEntry, Project)>, StintError>
pub fn get_entries( &self, filter: &EntryFilter, ) -> Result<Vec<(TimeEntry, Project)>, StintError>
Lists entries matching the given filter, enriched with project data.
Sourcepub fn get_last_entry(&self) -> Result<Option<(TimeEntry, Project)>, StintError>
pub fn get_last_entry(&self) -> Result<Option<(TimeEntry, Project)>, StintError>
Returns the most recent time entry with its project.
Sourcepub fn delete_entry(&self, id: &EntryId) -> Result<(), StintError>
pub fn delete_entry(&self, id: &EntryId) -> Result<(), StintError>
Deletes a time entry by ID.
Sourcepub fn update_entry(&self, entry: &TimeEntry) -> Result<(), StintError>
pub fn update_entry(&self, entry: &TimeEntry) -> Result<(), StintError>
Updates a time entry.
Sourcepub fn resolve_project_id(&self, name: &str) -> Result<ProjectId, StintError>
pub fn resolve_project_id(&self, name: &str) -> Result<ProjectId, StintError>
Resolves a project name to its ID for use in filters.