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
//! Events in the to-do system

use crate::domain;
use cqrs_core::Event;
use serde::{Deserialize, Serialize};

/// A to-do was created.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Created {
    /// The initial description assigned to the to-do item.
    pub initial_description: domain::Description,
}

impl Event for Created {
    fn event_type(&self) -> &'static str {
        "todo_created"
    }
}

/// The description was updated.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct DescriptionUpdated {
    /// The new description assigned to the to-do item.
    pub new_description: domain::Description,
}

impl Event for DescriptionUpdated {
    fn event_type(&self) -> &'static str {
        "todo_description_updated"
    }
}

/// The reminder was updated.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ReminderUpdated {
    /// The new reminder assigned to the to-do item.
    pub new_reminder: Option<domain::Reminder>,
}

impl Event for ReminderUpdated {
    fn event_type(&self) -> &'static str {
        "todo_reminder_updated"
    }
}

/// The activity was completed.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Completed {}

impl Event for Completed {
    fn event_type(&self) -> &'static str {
        "todo_completed"
    }
}

/// The activity's completion was undone.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Uncompleted {}

impl Event for Uncompleted {
    fn event_type(&self) -> &'static str {
        "todo_uncompleted"
    }
}