1use nom::{IResult, number::complete::u8};
2
3#[allow(non_camel_case_types)]
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6pub enum TapeColor {
7 None,
8 BerryPink_TZe_MQP35,
9 Black,
10 Blue_TZe_5_345_5,
11 Blue,
12 Cleaning,
13 Clear,
14 ClearMatte,
15 GoldSatin,
16 Green,
17 HeatShrinkTube,
18 Incompatible,
19 LightGray_TZe_MQL35,
20 LimeGreen_TZe_MQG35,
21 OrangeFluorescent,
22 Pink,
23 Red_TZe_435,
24 Red,
25 SilverMatte,
26 SilverSatin,
27 Stencil,
28 White,
29 WhiteFlexId,
30 WhiteMatte,
31 Yellow,
32 YellowFlexId,
33 YellowFluorescent,
34 Other,
35 Unknown(u8),
36}
37
38impl From<u8> for TapeColor {
39 fn from(value: u8) -> Self {
40 match value {
41 0x00 => TapeColor::None,
42 0x01 => TapeColor::White,
43 0x02 => TapeColor::Other,
44 0x03 => TapeColor::Clear,
45 0x04 => TapeColor::Red,
46 0x05 => TapeColor::Blue,
47 0x06 => TapeColor::Yellow,
48 0x07 => TapeColor::Green,
49 0x08 => TapeColor::Black,
50 0x09 => TapeColor::Clear,
51 0x20 => TapeColor::WhiteMatte,
52 0x21 => TapeColor::ClearMatte,
53 0x22 => TapeColor::SilverMatte,
54 0x23 => TapeColor::GoldSatin,
55 0x24 => TapeColor::SilverSatin,
56 0x30 => TapeColor::Blue_TZe_5_345_5,
57 0x31 => TapeColor::Red_TZe_435,
58 0x40 => TapeColor::OrangeFluorescent,
59 0x41 => TapeColor::YellowFluorescent,
60 0x50 => TapeColor::BerryPink_TZe_MQP35,
61 0x51 => TapeColor::LightGray_TZe_MQL35,
62 0x52 => TapeColor::LimeGreen_TZe_MQG35,
63 0x60 => TapeColor::Yellow,
64 0x61 => TapeColor::Pink,
65 0x62 => TapeColor::Blue,
66 0x70 => TapeColor::HeatShrinkTube,
67 0x90 => TapeColor::WhiteFlexId,
68 0x91 => TapeColor::YellowFlexId,
69 0xf0 => TapeColor::Cleaning,
70 0xf1 => TapeColor::Stencil,
71 0xff => TapeColor::Incompatible,
72 v => TapeColor::Unknown(v),
73 }
74 }
75}
76
77impl TapeColor {
78 pub fn parse(input: &[u8]) -> IResult<&[u8], Self> {
79 let (input, color) = u8(input)?;
80
81 Ok((input, color.into()))
82 }
83}