1#![allow(non_camel_case_types)]
6
7use serde_derive::{Deserialize, Serialize};
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
10#[non_exhaustive]
11pub enum Arch {
12 aarch64,
13 amdgpu,
14 arm,
15 arm64ec,
16 avr,
17 bpf,
18 csky,
19 hexagon,
20 loongarch32,
21 loongarch64,
22 m68k,
23 mips,
24 mips32r6,
25 mips64,
26 mips64r6,
27 msp430,
28 nvptx64,
29 powerpc,
30 powerpc64,
31 riscv32,
32 riscv64,
33 s390x,
34 sparc,
35 sparc64,
36 spirv,
37 wasm32,
38 wasm64,
39 x86,
40 x86_64,
41 xtensa,
42}
43impl Arch {
44 #[must_use]
45 pub fn as_str(self) -> &'static str {
46 match self {
47 Self::aarch64 => "aarch64",
48 Self::amdgpu => "amdgpu",
49 Self::arm => "arm",
50 Self::arm64ec => "arm64ec",
51 Self::avr => "avr",
52 Self::bpf => "bpf",
53 Self::csky => "csky",
54 Self::hexagon => "hexagon",
55 Self::loongarch32 => "loongarch32",
56 Self::loongarch64 => "loongarch64",
57 Self::m68k => "m68k",
58 Self::mips => "mips",
59 Self::mips32r6 => "mips32r6",
60 Self::mips64 => "mips64",
61 Self::mips64r6 => "mips64r6",
62 Self::msp430 => "msp430",
63 Self::nvptx64 => "nvptx64",
64 Self::powerpc => "powerpc",
65 Self::powerpc64 => "powerpc64",
66 Self::riscv32 => "riscv32",
67 Self::riscv64 => "riscv64",
68 Self::s390x => "s390x",
69 Self::sparc => "sparc",
70 Self::sparc64 => "sparc64",
71 Self::spirv => "spirv",
72 Self::wasm32 => "wasm32",
73 Self::wasm64 => "wasm64",
74 Self::x86 => "x86",
75 Self::x86_64 => "x86_64",
76 Self::xtensa => "xtensa",
77 }
78 }
79}
80impl core::fmt::Display for Arch {
81 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
82 f.write_str(self.as_str())
83 }
84}
85
86#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
87#[non_exhaustive]
88pub enum Os {
89 aix,
90 amdhsa,
91 android,
92 cuda,
93 cygwin,
94 dragonfly,
95 emscripten,
96 espidf,
97 freebsd,
98 fuchsia,
99 haiku,
100 helenos,
101 hermit,
102 horizon,
103 hurd,
104 illumos,
105 ios,
106 l4re,
107 linux,
108 lynxos178,
109 macos,
110 managarm,
111 motor,
112 netbsd,
113 #[default]
114 none,
115 nto,
116 nuttx,
117 openbsd,
118 psp,
119 psx,
120 qurt,
121 redox,
122 rtems,
123 solaris,
124 solid_asp3,
125 teeos,
126 trusty,
127 tvos,
128 uefi,
129 unknown,
130 vexos,
131 visionos,
132 vita,
133 vxworks,
134 wasi,
135 watchos,
136 windows,
137 xous,
138 zephyr,
139 zkvm,
140}
141impl Os {
142 #[must_use]
143 pub fn as_str(self) -> &'static str {
144 match self {
145 Self::aix => "aix",
146 Self::amdhsa => "amdhsa",
147 Self::android => "android",
148 Self::cuda => "cuda",
149 Self::cygwin => "cygwin",
150 Self::dragonfly => "dragonfly",
151 Self::emscripten => "emscripten",
152 Self::espidf => "espidf",
153 Self::freebsd => "freebsd",
154 Self::fuchsia => "fuchsia",
155 Self::haiku => "haiku",
156 Self::helenos => "helenos",
157 Self::hermit => "hermit",
158 Self::horizon => "horizon",
159 Self::hurd => "hurd",
160 Self::illumos => "illumos",
161 Self::ios => "ios",
162 Self::l4re => "l4re",
163 Self::linux => "linux",
164 Self::lynxos178 => "lynxos178",
165 Self::macos => "macos",
166 Self::managarm => "managarm",
167 Self::motor => "motor",
168 Self::netbsd => "netbsd",
169 Self::none => "none",
170 Self::nto => "nto",
171 Self::nuttx => "nuttx",
172 Self::openbsd => "openbsd",
173 Self::psp => "psp",
174 Self::psx => "psx",
175 Self::qurt => "qurt",
176 Self::redox => "redox",
177 Self::rtems => "rtems",
178 Self::solaris => "solaris",
179 Self::solid_asp3 => "solid_asp3",
180 Self::teeos => "teeos",
181 Self::trusty => "trusty",
182 Self::tvos => "tvos",
183 Self::uefi => "uefi",
184 Self::unknown => "unknown",
185 Self::vexos => "vexos",
186 Self::visionos => "visionos",
187 Self::vita => "vita",
188 Self::vxworks => "vxworks",
189 Self::wasi => "wasi",
190 Self::watchos => "watchos",
191 Self::windows => "windows",
192 Self::xous => "xous",
193 Self::zephyr => "zephyr",
194 Self::zkvm => "zkvm",
195 }
196 }
197}
198impl Os {
199 #[allow(clippy::trivially_copy_pass_by_ref)]
200 pub(crate) fn is_none(&self) -> bool {
201 matches!(self, Self::none)
202 }
203}
204impl core::fmt::Display for Os {
205 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
206 f.write_str(self.as_str())
207 }
208}
209
210#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
211#[non_exhaustive]
212pub enum Env {
213 gnu,
214 libnx,
215 macabi,
216 mlibc,
217 msvc,
218 musl,
219 newlib,
220 #[default]
221 none,
222 nto70,
223 nto71,
224 nto71_iosock,
225 nto80,
226 ohos,
227 p1,
228 p2,
229 p3,
230 relibc,
231 sgx,
232 sim,
233 uclibc,
234 v5,
235}
236impl Env {
237 #[must_use]
238 pub fn as_str(self) -> &'static str {
239 match self {
240 Self::gnu => "gnu",
241 Self::libnx => "libnx",
242 Self::macabi => "macabi",
243 Self::mlibc => "mlibc",
244 Self::msvc => "msvc",
245 Self::musl => "musl",
246 Self::newlib => "newlib",
247 Self::none => "",
248 Self::nto70 => "nto70",
249 Self::nto71 => "nto71",
250 Self::nto71_iosock => "nto71_iosock",
251 Self::nto80 => "nto80",
252 Self::ohos => "ohos",
253 Self::p1 => "p1",
254 Self::p2 => "p2",
255 Self::p3 => "p3",
256 Self::relibc => "relibc",
257 Self::sgx => "sgx",
258 Self::sim => "sim",
259 Self::uclibc => "uclibc",
260 Self::v5 => "v5",
261 }
262 }
263}
264impl Env {
265 #[allow(clippy::trivially_copy_pass_by_ref)]
266 pub(crate) fn is_none(&self) -> bool {
267 matches!(self, Self::none)
268 }
269}
270impl core::fmt::Display for Env {
271 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
272 f.write_str(self.as_str())
273 }
274}
275
276#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
277#[non_exhaustive]
278pub enum TargetFamily {
279 unix,
280 wasm,
281 windows,
282}
283impl TargetFamily {
284 #[must_use]
285 pub fn as_str(self) -> &'static str {
286 match self {
287 Self::unix => "unix",
288 Self::wasm => "wasm",
289 Self::windows => "windows",
290 }
291 }
292}
293impl core::fmt::Display for TargetFamily {
294 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
295 f.write_str(self.as_str())
296 }
297}
298
299#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
300#[non_exhaustive]
301pub enum Sanitizer {
302 address,
303 cfi,
304 dataflow,
305 hwaddress,
306 kcfi,
307 #[serde(rename = "kernel-address")]
308 kernel_address,
309 leak,
310 memory,
311 memtag,
312 realtime,
313 safestack,
314 #[serde(rename = "shadow-call-stack")]
315 shadow_call_stack,
316 thread,
317}
318impl Sanitizer {
319 #[must_use]
320 pub fn as_str(self) -> &'static str {
321 match self {
322 Self::address => "address",
323 Self::cfi => "cfi",
324 Self::dataflow => "dataflow",
325 Self::hwaddress => "hwaddress",
326 Self::kcfi => "kcfi",
327 Self::kernel_address => "kernel-address",
328 Self::leak => "leak",
329 Self::memory => "memory",
330 Self::memtag => "memtag",
331 Self::realtime => "realtime",
332 Self::safestack => "safestack",
333 Self::shadow_call_stack => "shadow-call-stack",
334 Self::thread => "thread",
335 }
336 }
337}
338impl core::fmt::Display for Sanitizer {
339 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
340 f.write_str(self.as_str())
341 }
342}
343
344#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
345#[non_exhaustive]
346pub enum BinaryFormat {
347 coff,
348 #[default]
349 elf,
350 #[serde(rename = "mach-o")]
351 mach_o,
352 wasm,
353 xcoff,
354}
355impl BinaryFormat {
356 #[must_use]
357 pub fn as_str(self) -> &'static str {
358 match self {
359 Self::coff => "coff",
360 Self::elf => "elf",
361 Self::mach_o => "mach-o",
362 Self::wasm => "wasm",
363 Self::xcoff => "xcoff",
364 }
365 }
366}
367impl BinaryFormat {
368 #[allow(clippy::trivially_copy_pass_by_ref)]
369 pub(crate) fn is_elf(&self) -> bool {
370 matches!(self, Self::elf)
371 }
372}
373impl core::fmt::Display for BinaryFormat {
374 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
375 f.write_str(self.as_str())
376 }
377}
378
379#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
380#[allow(clippy::exhaustive_enums)]
381pub enum TargetEndian {
382 big,
383 #[default]
384 little,
385}
386impl TargetEndian {
387 #[must_use]
388 pub fn as_str(self) -> &'static str {
389 match self {
390 Self::big => "big",
391 Self::little => "little",
392 }
393 }
394}
395impl TargetEndian {
396 #[allow(clippy::trivially_copy_pass_by_ref)]
397 pub(crate) fn is_little(&self) -> bool {
398 matches!(self, Self::little)
399 }
400}
401impl core::fmt::Display for TargetEndian {
402 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
403 f.write_str(self.as_str())
404 }
405}
406
407#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
408#[allow(clippy::exhaustive_enums)]
409pub enum PanicStrategy {
410 abort,
411 #[default]
412 unwind,
413}
414impl PanicStrategy {
415 #[must_use]
416 pub fn as_str(self) -> &'static str {
417 match self {
418 Self::abort => "abort",
419 Self::unwind => "unwind",
420 }
421 }
422}
423impl PanicStrategy {
424 #[allow(clippy::trivially_copy_pass_by_ref)]
425 pub(crate) fn is_unwind(&self) -> bool {
426 matches!(self, Self::unwind)
427 }
428}
429impl core::fmt::Display for PanicStrategy {
430 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
431 f.write_str(self.as_str())
432 }
433}