cargo_issue_lib/
config.rs

1use std::str::FromStr;
2
3#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
4#[cfg_attr(structopt, derive(structopt::StructOpt))]
5pub enum Mode {
6    /// Checks all tracked issues. More efficient than running the track macros during build time,
7    /// as it can asynchronously obtain all information.
8    Pipe,
9    /// Runs checks during build time. `Level::Warn` corresponds to build warnings, `Level::Error`
10    /// to build errors.
11    Emit(Level),
12    /// Performs no actions after parsing the attribute.
13    Noop,
14}
15
16impl FromStr for Mode {
17    type Err = &'static str;
18
19    fn from_str(s: &str) -> Result<Self, Self::Err> {
20        match s {
21            "Pipe" => Ok(Mode::Pipe),
22            "Emit(Warn)" => Ok(Mode::Emit(Level::Warn)),
23            "Emit(Error)" => Ok(Mode::Emit(Level::Error)),
24            _ => Err("unrecognized Mode"),
25        }
26    }
27}
28
29impl Default for Mode {
30    fn default() -> Self {
31        Mode::Emit(Level::Warn)
32    }
33}
34
35#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
36pub enum Level {
37    Warn,
38    Error,
39}