persistent_scheduler/core/
task_kind.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
4/// Defines the type of task to be executed.
5pub enum TaskKind {
6    /// Represents a cron job, which is scheduled to run at specific intervals.
7    Cron {
8        /// Schedule expression for Cron tasks.
9        schedule: String,
10        /// Timezone for the schedule expression.
11        timezone: String,
12    },
13
14    /// Represents a repeated job that runs at a regular interval.
15    Repeat {
16        /// Repeat interval for Repeat tasks, in seconds.
17        interval_seconds: u32
18    },
19
20    /// Represents a one-time job that runs once and then completes.
21    #[default]
22    Once,
23}
24
25impl std::fmt::Display for TaskKind {
26    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27        match self {
28            TaskKind::Cron { .. } => write!(f, "Cron"),
29            TaskKind::Repeat { .. } => write!(f, "Repeat"),
30            TaskKind::Once => write!(f, "Once"),
31        }
32    }
33}