Skip to main content

StintService

Struct StintService 

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

Source

pub fn new(storage: S) -> Self

Creates a new service wrapping the given storage backend.

Source

pub fn storage(&self) -> &S

Returns a reference to the underlying storage.

Source

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.

Source

pub fn stop_timer(&self) -> Result<(TimeEntry, Project), StintError>

Stops the currently running timer.

Fails if no timer is running.

Source

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.

Source

pub fn get_status(&self) -> Result<Option<(TimeEntry, Project)>, StintError>

Returns the currently running timer and its project, if any.

Source

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.

Source

pub fn delete_project(&self, name: &str) -> Result<String, StintError>

Deletes a project and all its entries.

Source

pub fn get_entries( &self, filter: &EntryFilter, ) -> Result<Vec<(TimeEntry, Project)>, StintError>

Lists entries matching the given filter, enriched with project data.

Source

pub fn get_last_entry(&self) -> Result<Option<(TimeEntry, Project)>, StintError>

Returns the most recent time entry with its project.

Source

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

Deletes a time entry by ID.

Source

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

Updates a time entry.

Source

pub fn resolve_project_id(&self, name: &str) -> Result<ProjectId, StintError>

Resolves a project name to its ID for use in filters.

Auto Trait Implementations§

§

impl<S> Freeze for StintService<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for StintService<S>
where S: RefUnwindSafe,

§

impl<S> Send for StintService<S>
where S: Send,

§

impl<S> Sync for StintService<S>
where S: Sync,

§

impl<S> Unpin for StintService<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for StintService<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for StintService<S>
where S: UnwindSafe,

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