1use crate::macros::*;
2use std::fmt::Display;
3
4__impls_for_short_items! {
5 Input: 0b1000_0000;
24 Output: 0b1001_0000;
41 Feature: 0b1011_0000;
59 Collection: 0b1010_0000;
75 EndCollection: 0b1100_0000;
78}
79
80impl Display for Input {
81 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
82 match self.data().len() {
83 0 => write!(f, "Input"),
84 1 => write!(
85 f,
86 "Input ({}, {}, {}, {}, {}, {}, {})",
87 __matches_bit!(self.data()[0], 0, "Data", "Constant"),
88 __matches_bit!(self.data()[0], 1, "Array", "Variable"),
89 __matches_bit!(self.data()[0], 2, "Absolute", "Relative"),
90 __matches_bit!(self.data()[0], 3, "No Wrap", "Wrap"),
91 __matches_bit!(self.data()[0], 4, "Linear", "Non Linear"),
92 __matches_bit!(self.data()[0], 5, "Preferred State", "No Preferred"),
93 __matches_bit!(self.data()[0], 6, "No Null Position", "Null State"),
94 ),
95 2.. => write!(
96 f,
97 "Input ({}, {}, {}, {}, {}, {}, {}, {})",
98 __matches_bit!(self.data()[0], 0, "Data", "Constant"),
99 __matches_bit!(self.data()[0], 1, "Array", "Variable"),
100 __matches_bit!(self.data()[0], 2, "Absolute", "Relative"),
101 __matches_bit!(self.data()[0], 3, "No Wrap", "Wrap"),
102 __matches_bit!(self.data()[0], 4, "Linear", "Non Linear"),
103 __matches_bit!(self.data()[0], 5, "Preferred State", "No Preferred"),
104 __matches_bit!(self.data()[0], 6, "No Null Position", "Null State"),
105 __matches_bit!(self.data()[1], 0, "Bit Field", "Buffered Bytes"),
106 ),
107 }
108 }
109}
110
111impl Display for Output {
112 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
113 match self.data().len() {
114 0 => write!(f, "Output"),
115 1 => write!(
116 f,
117 "Output ({}, {}, {}, {}, {}, {}, {}, {})",
118 __matches_bit!(self.data()[0], 0, "Data", "Constant"),
119 __matches_bit!(self.data()[0], 1, "Array", "Variable"),
120 __matches_bit!(self.data()[0], 2, "Absolute", "Relative"),
121 __matches_bit!(self.data()[0], 3, "No Wrap", "Wrap"),
122 __matches_bit!(self.data()[0], 4, "Linear", "Non Linear"),
123 __matches_bit!(self.data()[0], 5, "Preferred State", "No Preferred"),
124 __matches_bit!(self.data()[0], 6, "No Null Position", "Null State"),
125 __matches_bit!(self.data()[0], 7, "Non Volatile", "Volatile"),
126 ),
127 2.. => write!(
128 f,
129 "Output ({}, {}, {}, {}, {}, {}, {}, {}, {})",
130 __matches_bit!(self.data()[0], 0, "Data", "Constant"),
131 __matches_bit!(self.data()[0], 1, "Array", "Variable"),
132 __matches_bit!(self.data()[0], 2, "Absolute", "Relative"),
133 __matches_bit!(self.data()[0], 3, "No Wrap", "Wrap"),
134 __matches_bit!(self.data()[0], 4, "Linear", "Non Linear"),
135 __matches_bit!(self.data()[0], 5, "Preferred State", "No Preferred"),
136 __matches_bit!(self.data()[0], 6, "No Null Position", "Null State"),
137 __matches_bit!(self.data()[0], 7, "Non Volatile", "Volatile"),
138 __matches_bit!(self.data()[1], 0, "Bit Field", "Buffered Bytes"),
139 ),
140 }
141 }
142}
143
144impl Display for Feature {
145 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
146 match self.data().len() {
147 0 => write!(f, "Feature"),
148 1 => write!(
149 f,
150 "Feature ({}, {}, {}, {}, {}, {}, {}, {})",
151 __matches_bit!(self.data()[0], 0, "Data", "Constant"),
152 __matches_bit!(self.data()[0], 1, "Array", "Variable"),
153 __matches_bit!(self.data()[0], 2, "Absolute", "Relative"),
154 __matches_bit!(self.data()[0], 3, "No Wrap", "Wrap"),
155 __matches_bit!(self.data()[0], 4, "Linear", "Non Linear"),
156 __matches_bit!(self.data()[0], 5, "Preferred State", "No Preferred"),
157 __matches_bit!(self.data()[0], 6, "No Null Position", "Null State"),
158 __matches_bit!(self.data()[0], 7, "Non Volatile", "Volatile"),
159 ),
160 2.. => write!(
161 f,
162 "Feature ({}, {}, {}, {}, {}, {}, {}, {}, {})",
163 __matches_bit!(self.data()[0], 0, "Data", "Constant"),
164 __matches_bit!(self.data()[0], 1, "Array", "Variable"),
165 __matches_bit!(self.data()[0], 2, "Absolute", "Relative"),
166 __matches_bit!(self.data()[0], 3, "No Wrap", "Wrap"),
167 __matches_bit!(self.data()[0], 4, "Linear", "Non Linear"),
168 __matches_bit!(self.data()[0], 5, "Preferred State", "No Preferred"),
169 __matches_bit!(self.data()[0], 6, "No Null Position", "Null State"),
170 __matches_bit!(self.data()[0], 7, "Non Volatile", "Volatile"),
171 __matches_bit!(self.data()[1], 0, "Bit Field", "Buffered Bytes"),
172 ),
173 }
174 }
175}
176
177impl Display for Collection {
178 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
179 match self.data().len() {
180 0 => write!(f, "Collection"),
181 1.. => write!(
182 f,
183 "Collection ({})",
184 match self.data()[0] {
185 0 => "Physical",
186 1 => "Application",
187 2 => "Logical",
188 3 => "Report",
189 4 => "Named Array",
190 5 => "Usage Switch",
191 6 => "Usage Modifier",
192 7..=0x7f => "Reserved",
193 0x80..=0xff => "Vendor Defined",
194 }
195 ),
196 }
197 }
198}
199
200impl Display for EndCollection {
201 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
202 write!(f, "End Collection")
203 }
204}