Design command data types
This design went through a few iterations, and this won't be the last.
This commit is contained in:
parent
636c7e9ee7
commit
106111e7c6
5 changed files with 177 additions and 1 deletions
87
src/commands.rs
Normal file
87
src/commands.rs
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
|
||||
|
||||
#[derive(Debug)]
|
||||
struct DateDelta {
|
||||
years: i32,
|
||||
months: i32,
|
||||
weeks: i32,
|
||||
days: i32,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct TimeDelta {
|
||||
hours: i32,
|
||||
minutes: i32,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum EndDate {
|
||||
Fixed(NaiveDate),
|
||||
Delta(DateDelta),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum EndTime {
|
||||
Fixed(NaiveTime),
|
||||
Delta(TimeDelta),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct DateSpec {
|
||||
start: NaiveDate,
|
||||
end: Option<EndDate>,
|
||||
repeat: Option<DateDelta>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct TimeSpec {
|
||||
start: NaiveTime,
|
||||
end: Option<EndTime>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct WhenSpec {
|
||||
date: DateSpec,
|
||||
time: Option<TimeSpec>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Done {
|
||||
refering_to: Option<NaiveDate>,
|
||||
created_at: Option<NaiveDateTime>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Task {
|
||||
title: String,
|
||||
when: Option<WhenSpec>,
|
||||
desc: Option<String>,
|
||||
dones: Vec<Done>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Note {
|
||||
title: String,
|
||||
when: WhenSpec,
|
||||
desc: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum BirthdaySpec {
|
||||
Date(NaiveDate),
|
||||
DateWithoutYear { month: u8, day: u8 },
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Birthday {
|
||||
title: String,
|
||||
when: BirthdaySpec,
|
||||
desc: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum Command {
|
||||
Task(Task),
|
||||
Note(Note),
|
||||
Birthday(Birthday),
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
mod commands;
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue