use serde::{Deserialize, Serialize};

/// How a job is scheduled. Serialized as JSON in the database `schedule` column.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum Schedule {
    /// One-shot: fires once at a specific Unix millisecond timestamp, then disables.
    #[serde(rename = "at")]
    At { at: i64 },
    /// Recurring: fires every `every_ms` milliseconds.
    #[serde(rename = "every")]
    Every { every_ms: u64 },
    /// Recurring: fires on a cron schedule with optional timezone.
    #[serde(rename = "cron")]
    Cron { expr: String, tz: Option<String> },
}
