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
/// The result (so far) of the sending of an email to a particular recipient
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum DeliveryResult {
    /// Mail is queued to be sent, but no attempt has yet been made to send. This state should
    /// be moved through rather quickly.
    Queued,

    /// Mail sending has been deferred due to a transient error. Number of attempts and Error
    /// are included.
    Deferred(u8, String),

    /// Mail has been sent. Delivery response included.
    Delivered(String),

    /// Mail sending has failed due to a permanent error. Error is included.
    Failed(String),
}

impl DeliveryResult {
    pub fn completed(&self) -> bool {
        match *self {
            DeliveryResult::Queued | DeliveryResult::Deferred(_, _) => false,
            _ => true,
        }
    }
}