Trait pace_core::ActivityStateManagement
source · 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§
sourcefn hold_activity(
&self,
activity_id: ActivityGuid,
hold_opts: HoldOptions
) -> PaceResult<ActivityItem>
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.
sourcefn resume_activity(
&self,
activity_id: ActivityGuid,
resume_opts: ResumeOptions
) -> PaceResult<ActivityItem>
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. 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.
sourcefn resume_most_recent_activity(
&self,
resume_opts: ResumeOptions
) -> PaceOptResult<ActivityItem>
fn resume_most_recent_activity( &self, resume_opts: ResumeOptions ) -> PaceOptResult<ActivityItem>
sourcefn end_activity(
&self,
activity_id: ActivityGuid,
end_opts: EndOptions
) -> PaceResult<ActivityItem>
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.
sourcefn end_all_activities(
&self,
end_opts: EndOptions
) -> PaceOptResult<Vec<ActivityItem>>
fn end_all_activities( &self, end_opts: EndOptions ) -> PaceOptResult<Vec<ActivityItem>>
sourcefn end_all_active_intermissions(
&self,
end_opts: EndOptions
) -> PaceOptResult<Vec<ActivityGuid>>
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.
sourcefn end_last_unfinished_activity(
&self,
end_opts: EndOptions
) -> PaceOptResult<ActivityItem>
fn end_last_unfinished_activity( &self, end_opts: EndOptions ) -> PaceOptResult<ActivityItem>
sourcefn hold_most_recent_active_activity(
&self,
hold_opts: HoldOptions
) -> PaceOptResult<ActivityItem>
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.