summaryrefslogtreecommitdiffstats
path: root/src/status.rs
blob: f049983b2bd183bf6d76fc22a2394e428c430d83 (plain)
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
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//

//! Module containing `TaskStatus` type and trait impls

use std::fmt::{Display, Error as FmtError, Formatter};

/// Enum for status taskwarrior supports.
#[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
pub enum TaskStatus {
    /// Pending status type
    #[serde(rename = "pending")]
    Pending,

    /// Deleted status type
    #[serde(rename = "deleted")]
    Deleted,

    /// Completed status type
    #[serde(rename = "completed")]
    Completed,

    /// Waiting status type
    #[serde(rename = "waiting")]
    Waiting,

    /// Recurring status type
    #[serde(rename = "recurring")]
    Recurring,
}

impl Display for TaskStatus {
    fn fmt(&self, fmt: &mut Formatter) -> Result<(), FmtError> {
        match self {
            TaskStatus::Pending => write!(fmt, "Pending"),
            TaskStatus::Deleted => write!(fmt, "Deleted"),
            TaskStatus::Completed => write!(fmt, "Completed"),
            TaskStatus::Waiting => write!(fmt, "Waiting"),
            TaskStatus::Recurring => write!(fmt, "Recurring"),
        }
    }
}