1#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
3pub enum JceType {
4 U8,
6 Bool,
8 I16,
10 I32,
12 I64,
14 F32,
16 F64,
18 ShortString,
20 LongString,
22 Map,
24 List,
26 Struct,
28 StructEnd,
30 Empty,
32 Bytes,
34 Unknown,
36 UnInit,
38}
39
40impl From<u8> for JceType {
41 fn from(ty: u8) -> JceType {
42 match ty {
43 0 => JceType::U8,
44 1 => JceType::I16,
45 2 => JceType::I32,
46 3 => JceType::I64,
47 4 => JceType::F32,
48 5 => JceType::F64,
49 6 => JceType::ShortString,
50 7 => JceType::LongString,
51 8 => JceType::Map,
52 9 => JceType::List,
53 10 => JceType::Struct,
54 11 => JceType::StructEnd,
55 12 => JceType::Empty,
56 13 => JceType::Bytes,
57 _ => JceType::Unknown,
58 }
59 }
60}
61
62impl Default for JceType {
63 fn default() -> Self {
64 JceType::UnInit
65 }
66}
67
68impl std::fmt::Display for JceType {
69 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
70 match self {
71 JceType::U8 => write!(f, "U8"),
72 JceType::Bool => write!(f, "Bool"),
73 JceType::I16 => write!(f, "I16"),
74 JceType::I32 => write!(f, "I32"),
75 JceType::I64 => write!(f, "I64"),
76 JceType::F32 => write!(f, "F32"),
77 JceType::F64 => write!(f, "F64"),
78 JceType::ShortString => write!(f, "ShortString"),
79 JceType::LongString => write!(f, "LongString"),
80 JceType::Map => write!(f, "Map"),
81 JceType::List => write!(f, "List"),
82 JceType::Struct => write!(f, "Struct"),
83 JceType::StructEnd => write!(f, "StructEnd"),
84 JceType::Empty => write!(f, "Empty"),
85 JceType::Bytes => write!(f, "Bytes"),
86 JceType::Unknown => write!(f, "Unknown"),
87 JceType::UnInit => write!(f, "UnInit"),
88 }
89 }
90}
91
92#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
94pub struct JceHead {
95 pub ty: JceType,
96 pub tag: u8,
97}