1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
pub mod project;
pub mod item;
pub mod label;
pub mod filter;
pub mod note;

use uuid::Uuid;
use types::ID;
use erased_serde;

pub enum MoveTargetType {
    Project,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
/// Identity is used to identify Todoist objects, 
/// it's typically used as arguments to a command, where a single action
/// is performed on an object. (e.g. delete)
pub struct Identity {
    pub ids : Vec<ID>,
}


#[derive(Serialize)]
pub struct Command {
    #[serde(rename = "type")]
    pub typ     : String,
    pub args    : Box<erased_serde::Serialize>,
    pub uuid    : Uuid,
    pub temp_id : Option<Uuid>, 
}

pub trait Update {
    fn update(self) -> Command;
}

pub trait Complete {
    fn complete(self) -> Command;
    fn uncomplete(self) -> Command;
}

pub trait Delete {
    fn delete(self) -> Command;
}

pub trait Create {
    fn create(self) -> Command;
}


pub trait Close {
    fn close(self) -> Command;
}

pub trait MoveObject {
    fn move_object(self, &MoveTarget) -> Command;
}

pub trait MoveTarget {
    fn target_type(&self) -> MoveTargetType;
    fn target_id(&self) -> ID;
}

pub trait Archive {
    fn archive(self) -> Command;
    fn unarchive(self) -> Command;
}

pub trait Unarchive {
    fn update(self) -> Command;
}