Skip to main content

just/
verbosity.rs

1#[allow(clippy::arbitrary_source_item_ordering)]
2#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
3pub(crate) enum Verbosity {
4  Quiet,
5  Taciturn,
6  Loquacious,
7  Grandiloquent,
8}
9
10impl Verbosity {
11  pub(crate) fn from_flag_occurrences(flag_occurrences: u8) -> Self {
12    match flag_occurrences {
13      0 => Self::Taciturn,
14      1 => Self::Loquacious,
15      _ => Self::Grandiloquent,
16    }
17  }
18
19  pub(crate) fn quiet(self) -> bool {
20    self == Self::Quiet
21  }
22
23  pub(crate) fn loud(self) -> bool {
24    !self.quiet()
25  }
26
27  pub(crate) fn loquacious(self) -> bool {
28    self >= Self::Loquacious
29  }
30
31  pub(crate) fn grandiloquent(self) -> bool {
32    self >= Self::Grandiloquent
33  }
34
35  pub(crate) const fn default() -> Self {
36    Self::Taciturn
37  }
38}
39
40impl Default for Verbosity {
41  fn default() -> Self {
42    Self::default()
43  }
44}