1#[derive(Copy, Clone, Debug, PartialEq, Eq)]
3#[allow(clippy::exhaustive_enums)]
4pub enum ColorMode {
5 TwoTone,
7 ThreeBit,
9 FourBit,
11 EightBit,
13 TrueColor,
15}
16
17impl ColorMode {
18 #[inline]
20 #[must_use]
21 pub fn has_minimum_four_bit_color(self) -> bool {
22 self == Self::FourBit || self == Self::EightBit || self == Self::TrueColor
23 }
24
25 #[inline]
27 #[must_use]
28 pub fn has_true_color(self) -> bool {
29 self == Self::TrueColor
30 }
31}
32
33#[cfg(test)]
34mod tests {
35 use super::*;
36
37 #[test]
38 fn color_mode_has_minimum_four_bit_color_two_tone() {
39 assert!(!ColorMode::TwoTone.has_minimum_four_bit_color());
40 }
41
42 #[test]
43 fn color_mode_has_minimum_four_bit_color_three_bit() {
44 assert!(!ColorMode::ThreeBit.has_minimum_four_bit_color());
45 }
46
47 #[test]
48 fn color_mode_has_minimum_four_bit_color_four_bit() {
49 assert!(ColorMode::FourBit.has_minimum_four_bit_color());
50 }
51
52 #[test]
53 fn color_mode_has_minimum_four_bit_color_eight_bit() {
54 assert!(ColorMode::EightBit.has_minimum_four_bit_color());
55 }
56
57 #[test]
58 fn color_mode_has_minimum_four_bit_color_true_color() {
59 assert!(ColorMode::TrueColor.has_minimum_four_bit_color());
60 }
61
62 #[test]
63 fn color_mode_has_true_color_two_tone() {
64 assert!(!ColorMode::TwoTone.has_true_color());
65 }
66
67 #[test]
68 fn color_mode_has_true_color_three_bit() {
69 assert!(!ColorMode::ThreeBit.has_true_color());
70 }
71
72 #[test]
73 fn color_mode_has_true_color_four_bit() {
74 assert!(!ColorMode::FourBit.has_true_color());
75 }
76
77 #[test]
78 fn color_mode_has_true_color_eight_bit() {
79 assert!(!ColorMode::EightBit.has_true_color());
80 }
81
82 #[test]
83 fn color_mode_has_true_color_true_color() {
84 assert!(ColorMode::TrueColor.has_true_color());
85 }
86}