43 lines
1 KiB
Rust
43 lines
1 KiB
Rust
#[derive(Debug, Clone)]
|
|
pub struct Task {
|
|
/// Issue Number for referencing the task
|
|
pub issue_number: u64,
|
|
|
|
/// 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 and pending completion.
|
|
///
|
|
/// An optional due date may be present.
|
|
Open { due: Option<time::OffsetDateTime> },
|
|
|
|
/// The task has been completed at the specified time.
|
|
Completed { date: time::OffsetDateTime },
|
|
}
|
|
|
|
#[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)
|
|
}
|
|
}
|