pub trait ActivityStateManagement: ActivityReadOps + ActivityWriteOps {
    // Required methods
    fn end_single_activity(
        &self,
        activity_id: ActivityGuid,
        end_time: Option<NaiveDateTime>
    ) -> PaceResult<ActivityGuid>;
    fn end_all_unfinished_activities(
        &self,
        end_time: Option<NaiveDateTime>
    ) -> PaceOptResult<Vec<Activity>>;
    fn end_last_unfinished_activity(
        &self,
        end_time: Option<NaiveDateTime>
    ) -> PaceOptResult<Activity>;
    fn hold_last_unfinished_activity(
        &self,
        end_time: Option<NaiveDateTime>
    ) -> PaceOptResult<Activity>;

    // Provided method
    fn begin_activity(&self, activity: Activity) -> PaceResult<ActivityGuid> { ... }
}
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 end_single_activity( &self, activity_id: ActivityGuid, end_time: Option<NaiveDateTime> ) -> PaceResult<ActivityGuid>

End an activity in the storage backend.

§Arguments
  • activity_id - The ID of the activity to end.
  • end_time - The time (HH:MM) to end the activity at. If None, the current time is used.
§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, end_time: Option<NaiveDateTime> ) -> PaceOptResult<Vec<Activity>>

End all unfinished activities in the storage backend.

§Arguments
  • time - The time (HH:MM) to end the activities at. If None, the current time is used.
§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_last_unfinished_activity( &self, end_time: Option<NaiveDateTime> ) -> PaceOptResult<Activity>

End the last unfinished activity in the storage backend.

§Arguments
  • time - The time (HH:MM) to end the activity at. If None, the current time is used.
§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_last_unfinished_activity( &self, end_time: Option<NaiveDateTime> ) -> PaceOptResult<Activity>

Hold an activity in the storage backend.

§Arguments
  • time - The time (HH:MM) to hold the activity at. If None, the current time is used.
§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).

Provided Methods§

source

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

Start an activity in the storage backend.

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