Enum pace_core::StorageKind
source · pub enum StorageKind {
ActivityStore(ActivityStore),
InMemoryActivityStorage(InMemoryActivityStorage),
TomlActivityStorage(TomlActivityStorage),
}
Variants§
ActivityStore(ActivityStore)
InMemoryActivityStorage(InMemoryActivityStorage)
TomlActivityStorage(TomlActivityStorage)
Trait Implementations§
source§impl ActivityQuerying for StorageKind
impl ActivityQuerying for StorageKind
source§fn group_activities_by_duration_range(
&self
) -> PaceOptResult<BTreeMap<PaceDurationRange, Vec<ActivityItem>>>
fn group_activities_by_duration_range( &self ) -> PaceOptResult<BTreeMap<PaceDurationRange, Vec<ActivityItem>>>
Group activities by predefined duration ranges (e.g., short, medium, long).
This is useful for analyzing how time is spent on different activities.
§Errors
This function should return an error if the activities cannot be loaded.
§Returns
A collection of the activities that are grouped by their duration range.
The key is the duration range, and the value is a list of activities that
fall within that range.
If no activities are found, it should return Ok(None)
.
source§fn group_activities_by_start_date(
&self
) -> PaceOptResult<BTreeMap<PaceDate, Vec<ActivityItem>>>
fn group_activities_by_start_date( &self ) -> PaceOptResult<BTreeMap<PaceDate, Vec<ActivityItem>>>
Group activities by their start date. This can help in analyzing how activities are distributed over time.
§Errors
This function should return an error if the activities cannot be loaded.
§Returns
A collection of the activities that are grouped by their start date. The key is the start date of the activity, and the value is a list of activities that started on that date.
source§fn list_activities_with_intermissions(
&self
) -> PaceOptResult<BTreeMap<ActivityGuid, Vec<ActivityItem>>>
fn list_activities_with_intermissions( &self ) -> PaceOptResult<BTreeMap<ActivityGuid, Vec<ActivityItem>>>
Retrieve activities that have one or more intermissions, useful for identifying potential inefficiencies or breaks.
§Errors
This function should return an error if the activities cannot be loaded.
§Returns
A collection of the activities that have intermissions.
The key is the ID of the activity, and the value is a list of intermissions.
If no activities are found, it should return Ok(None)
.
source§fn group_activities_by_keywords(
&self,
__enum_dispatch_arg_0: KeywordOptions
) -> PaceOptResult<BTreeMap<String, Vec<ActivityItem>>>
fn group_activities_by_keywords( &self, __enum_dispatch_arg_0: KeywordOptions ) -> PaceOptResult<BTreeMap<String, Vec<ActivityItem>>>
Group activities based on keywords, e.g., category, tags, etc.
This is useful for analyzing time spent on different projects or areas of work.
§Arguments
keyword_opts
- The keyword options to filter the activities by.
§Errors
This function should return an error if the activities cannot be loaded.
§Returns
A collection of the activities that are matching the KeywordOptions
.
The key is the keyword, and the value is a list of matching activities.
If no activities are found, it should return Ok(None)
.
source§fn group_activities_by_kind(
&self
) -> PaceOptResult<BTreeMap<ActivityKind, Vec<ActivityItem>>>
fn group_activities_by_kind( &self ) -> PaceOptResult<BTreeMap<ActivityKind, Vec<ActivityItem>>>
Group activities based on their kind (e.g., Task, Intermission).
§Errors
This function should return an error if the activities cannot be loaded.
§Returns
A collection of the activities with their kind.
The key is the kind of the activity, and the value is a list of activities of that kind.
If no activities are found, it should return Ok(None)
.
source§fn list_activities_by_time_range(
&self,
__enum_dispatch_arg_0: TimeRangeOptions
) -> PaceOptResult<Vec<ActivityItem>>
fn list_activities_by_time_range( &self, __enum_dispatch_arg_0: TimeRangeOptions ) -> PaceOptResult<Vec<ActivityItem>>
List activities by time range from the storage backend.
§Arguments
time_range_opts
- The range options to filter the activities by.
§Errors
This function should return an error if the activities cannot be loaded.
§Returns
A collection of the activities that are matching the RangeOptions
.
If no activities are found, it should return Ok(None)
.
source§fn group_activities_by_status(
&self
) -> PaceOptResult<BTreeMap<ActivityStatus, Vec<ActivityItem>>>
fn group_activities_by_status( &self ) -> PaceOptResult<BTreeMap<ActivityStatus, Vec<ActivityItem>>>
source§fn list_current_activities(
&self,
__enum_dispatch_arg_0: ActivityStatusFilter
) -> PaceOptResult<Vec<ActivityGuid>>
fn list_current_activities( &self, __enum_dispatch_arg_0: ActivityStatusFilter ) -> PaceOptResult<Vec<ActivityGuid>>
source§fn list_activities_by_id(
&self
) -> PaceOptResult<BTreeMap<ActivityGuid, Activity>>
fn list_activities_by_id( &self ) -> PaceOptResult<BTreeMap<ActivityGuid, Activity>>
source§fn list_active_intermissions(&self) -> PaceOptResult<Vec<ActivityGuid>>
fn list_active_intermissions(&self) -> PaceOptResult<Vec<ActivityGuid>>
source§fn list_most_recent_activities(
&self,
__enum_dispatch_arg_0: usize
) -> PaceOptResult<Vec<ActivityGuid>>
fn list_most_recent_activities( &self, __enum_dispatch_arg_0: usize ) -> PaceOptResult<Vec<ActivityGuid>>
source§fn is_activity_active(
&self,
__enum_dispatch_arg_0: ActivityGuid
) -> PaceResult<bool>
fn is_activity_active( &self, __enum_dispatch_arg_0: ActivityGuid ) -> PaceResult<bool>
source§fn list_active_intermissions_for_activity_id(
&self,
__enum_dispatch_arg_0: ActivityGuid
) -> PaceOptResult<Vec<ActivityGuid>>
fn list_active_intermissions_for_activity_id( &self, __enum_dispatch_arg_0: ActivityGuid ) -> PaceOptResult<Vec<ActivityGuid>>
Check if an activity currently has one or more active intermissions.
§Arguments
activity_id
- The ID of the activity to check.
§Errors
This function should return an error if the activity cannot be checked.
§Returns
If the activity has active intermissions, it should return Ok(Option<VecDeque<ActivityGuid>>)
with the IDs of the active intermissions.
If it has no active intermissions, it should return Ok(None)
.
source§fn most_recent_active_activity(&self) -> PaceOptResult<ActivityItem>
fn most_recent_active_activity(&self) -> PaceOptResult<ActivityItem>
source§fn most_recent_held_activity(&self) -> PaceOptResult<ActivityItem>
fn most_recent_held_activity(&self) -> PaceOptResult<ActivityItem>
source§impl ActivityReadOps for StorageKind
impl ActivityReadOps for StorageKind
source§fn read_activity(
&self,
__enum_dispatch_arg_0: ActivityGuid
) -> PaceResult<ActivityItem>
fn read_activity( &self, __enum_dispatch_arg_0: ActivityGuid ) -> PaceResult<ActivityItem>
source§fn list_activities(
&self,
__enum_dispatch_arg_0: ActivityStatusFilter
) -> PaceOptResult<FilteredActivities>
fn list_activities( &self, __enum_dispatch_arg_0: ActivityStatusFilter ) -> PaceOptResult<FilteredActivities>
List activities from the storage backend.
§Arguments
filter
- The filter to apply to the activities.
§Errors
This function should return an error if the activities cannot be loaded.
§Returns
A collection of the activities that were loaded from the storage backend. Returns Ok(None) if no activities are found.
source§impl ActivityStateManagement for StorageKind
impl ActivityStateManagement for StorageKind
source§fn begin_activity(
&self,
__enum_dispatch_arg_0: Activity
) -> PaceResult<ActivityItem>
fn begin_activity( &self, __enum_dispatch_arg_0: Activity ) -> PaceResult<ActivityItem>
source§fn hold_activity(
&self,
__enum_dispatch_arg_0: ActivityGuid,
__enum_dispatch_arg_1: HoldOptions
) -> PaceResult<ActivityItem>
fn hold_activity( &self, __enum_dispatch_arg_0: ActivityGuid, __enum_dispatch_arg_1: HoldOptions ) -> PaceResult<ActivityItem>
Hold an activity in the storage backend.
§Arguments
activity_id
- The ID of the activity to hold.hold_opts
- The options to hold the activity.
§Errors
This function should return an error if the activity cannot be held.
§Returns
If the activity was held successfully it should return the ActivityItem
of the held activity.
source§fn resume_activity(
&self,
__enum_dispatch_arg_0: ActivityGuid,
__enum_dispatch_arg_1: ResumeOptions
) -> PaceResult<ActivityItem>
fn resume_activity( &self, __enum_dispatch_arg_0: ActivityGuid, __enum_dispatch_arg_1: ResumeOptions ) -> PaceResult<ActivityItem>
Resume an activity in the storage backend.
§Arguments
activity_id
- The ID of the activity to resume. IfNone
, the last unfinished activity is resumed.resume_time
- The time (HH:MM) to resume the activity at. IfNone
, the current time is used.
§Errors
This function should return an error if the activity cannot be resumed.
§Returns
The activity that was resumed. Returns Ok(None) if no activity was resumed.
source§fn resume_most_recent_activity(
&self,
__enum_dispatch_arg_0: ResumeOptions
) -> PaceOptResult<ActivityItem>
fn resume_most_recent_activity( &self, __enum_dispatch_arg_0: ResumeOptions ) -> PaceOptResult<ActivityItem>
source§fn end_activity(
&self,
__enum_dispatch_arg_0: ActivityGuid,
__enum_dispatch_arg_1: EndOptions
) -> PaceResult<ActivityItem>
fn end_activity( &self, __enum_dispatch_arg_0: ActivityGuid, __enum_dispatch_arg_1: EndOptions ) -> PaceResult<ActivityItem>
End an activity in the storage backend.
§Arguments
activity_id
- The ID of the activity to end.end_opts
- The options to end the activity.
§Errors
This function should return an error if the activity cannot be ended.
§Returns
If the activity was ended successfully it should return the ID of the ended activity.
source§fn end_all_unfinished_activities(
&self,
__enum_dispatch_arg_0: EndOptions
) -> PaceOptResult<Vec<ActivityItem>>
fn end_all_unfinished_activities( &self, __enum_dispatch_arg_0: EndOptions ) -> PaceOptResult<Vec<ActivityItem>>
source§fn end_all_active_intermissions(
&self,
__enum_dispatch_arg_0: EndOptions
) -> PaceOptResult<Vec<ActivityGuid>>
fn end_all_active_intermissions( &self, __enum_dispatch_arg_0: EndOptions ) -> PaceOptResult<Vec<ActivityGuid>>
End all active intermissions in the storage backend.
§Arguments
end_opts
- The options to end the intermissions.
§Errors
This function should return an error if the intermissions cannot be ended.
§Returns
A collection of the intermissions that were ended. Returns Ok(None) if no intermissions were ended.
source§fn end_last_unfinished_activity(
&self,
__enum_dispatch_arg_0: EndOptions
) -> PaceOptResult<ActivityItem>
fn end_last_unfinished_activity( &self, __enum_dispatch_arg_0: EndOptions ) -> PaceOptResult<ActivityItem>
source§fn hold_most_recent_active_activity(
&self,
__enum_dispatch_arg_0: HoldOptions
) -> PaceOptResult<ActivityItem>
fn hold_most_recent_active_activity( &self, __enum_dispatch_arg_0: HoldOptions ) -> PaceOptResult<ActivityItem>
Hold the most recent activity that is active in the storage backend.
§Arguments
hold_opts
- The options to hold the activity.
§Errors
This function should return an error if the activity cannot be held or if there are no activities to hold.
§Returns
The activity that was held if there was an unfinished activity to hold.
If there are no activities to hold, it should return Ok(None)
.
§Note
This function should not be used to hold an activity that is already held. It should only be used to hold the last unfinished activity.
source§impl ActivityStorage for StorageKind
impl ActivityStorage for StorageKind
source§fn setup_storage(&self) -> PaceResult<()>
fn setup_storage(&self) -> PaceResult<()>
Setup the storage backend. This is called once when the application starts.
This is where you would create the database tables, open the file, etc.
§Errors
This function should return an error if the storage backend cannot be setup.
source§impl ActivityWriteOps for StorageKind
impl ActivityWriteOps for StorageKind
source§fn create_activity(
&self,
__enum_dispatch_arg_0: Activity
) -> PaceResult<ActivityItem>
fn create_activity( &self, __enum_dispatch_arg_0: Activity ) -> PaceResult<ActivityItem>
source§fn update_activity(
&self,
__enum_dispatch_arg_0: ActivityGuid,
__enum_dispatch_arg_1: Activity,
__enum_dispatch_arg_2: UpdateOptions
) -> PaceResult<ActivityItem>
fn update_activity( &self, __enum_dispatch_arg_0: ActivityGuid, __enum_dispatch_arg_1: Activity, __enum_dispatch_arg_2: UpdateOptions ) -> PaceResult<ActivityItem>
Update an existing activity in the storage backend.
§Note
This function should not be used to update the state of an activity (e.g., start, end, hold, resume) directly.
Use the ActivityStateManagement
trait for that. This function is only for updating (as in replacing) the complete
data of an activity.
Warning: It can’t be used to update the ID of an activity, because that’s the primary key. So it is immutable.
§Arguments
activity_id
- The ID of the activity to update.activity
- The updated activity data.
§Errors
This function should return an error if the activity cannot be updated.
§Returns
If the activity was updated successfully it should return the original activity before it was updated.
source§fn delete_activity(
&self,
__enum_dispatch_arg_0: ActivityGuid,
__enum_dispatch_arg_1: DeleteOptions
) -> PaceResult<ActivityItem>
fn delete_activity( &self, __enum_dispatch_arg_0: ActivityGuid, __enum_dispatch_arg_1: DeleteOptions ) -> PaceResult<ActivityItem>
source§impl From<ActivityStore> for StorageKind
impl From<ActivityStore> for StorageKind
source§fn from(v: ActivityStore) -> StorageKind
fn from(v: ActivityStore) -> StorageKind
source§impl From<InMemoryActivityStorage> for StorageKind
impl From<InMemoryActivityStorage> for StorageKind
source§fn from(v: InMemoryActivityStorage) -> StorageKind
fn from(v: InMemoryActivityStorage) -> StorageKind
source§impl From<TomlActivityStorage> for StorageKind
impl From<TomlActivityStorage> for StorageKind
source§fn from(v: TomlActivityStorage) -> StorageKind
fn from(v: TomlActivityStorage) -> StorageKind
source§impl SyncStorage for StorageKind
impl SyncStorage for StorageKind
source§impl TryInto<ActivityStore> for StorageKind
impl TryInto<ActivityStore> for StorageKind
source§impl TryInto<InMemoryActivityStorage> for StorageKind
impl TryInto<InMemoryActivityStorage> for StorageKind
source§impl TryInto<TomlActivityStorage> for StorageKind
impl TryInto<TomlActivityStorage> for StorageKind
Auto Trait Implementations§
impl !RefUnwindSafe for StorageKind
impl Send for StorageKind
impl Sync for StorageKind
impl Unpin for StorageKind
impl !UnwindSafe for StorageKind
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
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read more