granger 0.1.0

An opinionated Kanban Board for the solo developer
Documentation
use serde::Serialize;

pub const TODO: &str = "todo";
pub const BLOCKED: &str = "blocked";
pub const DOING: &str = "doing";
pub const REVIEW: &str = "review";
pub const DONE: &str = "done";

#[derive(Debug, Eq, Hash, PartialEq, Serialize)]
pub enum State {
    ToDo,
    Blocked,
    Doing,
    Review,
    Done,
}

impl State {
    #[allow(clippy::inherent_to_string)]
    pub fn to_string(&self) -> String {
        match self {
            Self::ToDo => String::from(TODO),
            Self::Blocked => String::from(BLOCKED),
            Self::Doing => String::from(DOING),
            Self::Review => String::from(REVIEW),
            Self::Done => String::from(DONE),
        }
    }

    pub fn from_string(state_as_string: &str) -> State {
        match state_as_string {
            TODO => State::ToDo,
            BLOCKED => State::Blocked,
            DOING => State::Doing,
            REVIEW => State::Review,
            DONE => State::Done,
            _ => panic!(
                "Invalid state. Valid states are '{}', '{}', '{}', '{}', '{}'",
                TODO, BLOCKED, DOING, REVIEW, DONE
            ),
        }
    }
}