pub trait ActivityStateManagement: ActivityReadOps + ActivityWriteOps + ActivityQuerying {
    // Required methods
    fn hold_activity(
        &self,
        activity_id: ActivityGuid,
        hold_opts: HoldOptions
    ) -> PaceResult<ActivityItem>;
    fn resume_activity(
        &self,
        activity_id: ActivityGuid,
        resume_opts: ResumeOptions
    ) -> PaceResult<ActivityItem>;
    fn resume_most_recent_activity(
        &self,
        resume_opts: ResumeOptions
    ) -> PaceOptResult<ActivityItem>;
    fn end_activity(
        &self,
        activity_id: ActivityGuid,
        end_opts: EndOptions
    ) -> PaceResult<ActivityItem>;
    fn end_all_activities(
        &self,
        end_opts: EndOptions
    ) -> PaceOptResult<Vec<ActivityItem>>;
    fn end_all_active_intermissions(
        &self,
        end_opts: EndOptions
    ) -> PaceOptResult<Vec<ActivityGuid>>;
    fn end_last_unfinished_activity(
        &self,
        end_opts: EndOptions
    ) -> PaceOptResult<ActivityItem>;
    fn hold_most_recent_active_activity(
        &self,
        hold_opts: HoldOptions
    ) -> PaceOptResult<ActivityItem>;

    // Provided method
    fn begin_activity(&self, activity: Activity) -> PaceResult<ActivityItem> { ... }
}
Expand description

Managing Activity State

Managing activity state is a way to start, end, hold, or resume activities in the storage backend. This is useful for keeping track of the current state of activities and making sure they are properly managed.

For example, you might want to start a new activity, end an activity that is currently running, or hold an activity temporarily.

Required Methods§

source

fn hold_activity( &self, activity_id: ActivityGuid, hold_opts: 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, activity_id: ActivityGuid, resume_opts: ResumeOptions ) -> PaceResult<ActivityItem>

Resume an activity in the storage backend.

§Arguments
  • activity_id - The ID of the activity to resume. If None, the last unfinished activity is resumed.
  • resume_time - The time (HH:MM) to resume the activity at. If None, 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, resume_opts: ResumeOptions ) -> PaceOptResult<ActivityItem>

Resume the most recent activity in the storage backend.

§Arguments
  • resume_opts - The options to resume the activity.
§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 end_activity( &self, activity_id: ActivityGuid, end_opts: 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_activities( &self, end_opts: EndOptions ) -> PaceOptResult<Vec<ActivityItem>>

End all activities in the storage backend.

§Arguments
  • end_opts - The options to end the activities.
§Errors

This function should return an error if the activities cannot be ended.

§Returns

A collection of the activities that were ended. Returns Ok(None) if no activities were ended.

source

fn end_all_active_intermissions( &self, end_opts: 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, end_opts: EndOptions ) -> PaceOptResult<ActivityItem>

End the last unfinished activity in the storage backend.

§Arguments
  • end_opts - The options to end the activity.
§Errors

This function should return an error if the activity cannot be ended.

§Returns

The activity that was ended. Returns Ok(None) if no activity was ended.

source

fn hold_most_recent_active_activity( &self, hold_opts: 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.

Provided Methods§

source

fn begin_activity(&self, activity: Activity) -> PaceResult<ActivityItem>

Begin an activity in the storage backend. This makes the activity active.

§Arguments
  • activity - The activity to start.
§Errors

This function should return an error if the activity cannot be started.

§Returns

If the activity was started successfully it should return the ID of the started activity.

Implementors§