TaskBot/src/task.rs
Rahix 64d28bb868 Collect start date and reminder state
Already fetch the start date and reminder state for issues immediately
and have them available in the struct Task.
2026-03-05 20:42:25 +01:00

58 lines
1.3 KiB
Rust

#[derive(Debug, Clone)]
pub struct Task {
/// Issue Number for referencing the task
pub issue_number: u32,
/// Human-readable summary of the task
pub title: String,
/// Whether the task is open or has been completed
pub state: State,
/// Whether the task is a recurring one and metadata for rescheduling
pub recurring: Option<Recurring>,
}
#[derive(Debug, Clone)]
pub enum State {
/// The task is open but has no due date.
Open,
/// The task is scheduled and waiting for completion.
Scheduled(ScheduledInfo),
/// The task has been completed at the specified time.
Completed { date: jiff::Zoned },
}
#[derive(Debug, Clone)]
pub struct ScheduledInfo {
pub due_date: jiff::Zoned,
pub start_date: jiff::Zoned,
pub reminded: ReminderState,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ReminderState {
NotReminded,
Reminded { date: jiff::Zoned },
RemindedUrgently { date: jiff::Zoned },
}
#[derive(Debug, Clone)]
pub struct Recurring {
pub interval: RecurringInterval,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RecurringInterval {
Months(u32),
Weeks(u32),
Days(u32),
}
impl std::fmt::Display for Task {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "#{} — \"{}\"", self.issue_number, self.title)
}
}