bare-types 0.3.0

A zero-cost foundation for type-safe domain modeling in Rust. Implements the 'Parse, don't validate' philosophy to eliminate primitive obsession and ensure data integrity at the system boundary.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
//! Operating system type for system information.
//!
//! This module provides a type-safe abstraction for operating system types,
//! ensuring valid OS identifiers and providing convenient constants
//! for common operating systems.
//!
//! # Supported Operating Systems
//!
//! This type supports all major operating systems:
//!
//! - **Linux**: GNU/Linux distributions
//! - **`MacOS`**: macOS (formerly OS X)
//! - **Windows**: Microsoft Windows
//! - **FreeBSD**: FreeBSD operating system
//! - **OpenBSD**: OpenBSD operating system
//! - **NetBSD**: NetBSD operating system
//! - **`DragonFly`**: `DragonFly` BSD
//! - **Solaris**: Oracle Solaris
//! - **Illumos**: Illumos-based systems (`OpenIndiana`, etc.)
//! - **Android**: Android mobile OS
//! - **iOS**: Apple iOS
//! - **Redox**: Redox OS (Rust-based)
//! - **Fuchsia**: Google Fuchsia
//! - **Hermit**: `HermitCore` unikernel
//! - **`VxWorks`**: Wind River `VxWorks`
//! - **AIX**: IBM AIX
//! - **Haiku**: Haiku OS
//!
//! # Examples
//!
//! ```rust
//! use bare_types::sys::OsType;
//!
//! // Get current OS (compile-time constant)
//! let os = OsType::current();
//!
//! // Check OS family
//! assert!(os.is_unix() || os.is_windows());
//!
//! // Parse from string
//! let os: OsType = "linux".parse()?;
//! assert_eq!(os, OsType::LINUX);
//! # Ok::<(), bare_types::sys::OsTypeError>(())
//! ```

use core::fmt;
use core::str::FromStr;

#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

#[cfg(feature = "arbitrary")]
use arbitrary::Arbitrary;

/// Error type for OS type parsing.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[non_exhaustive]
pub enum OsTypeError {
    /// Unknown operating system string
    ///
    /// The provided string does not match any known operating system.
    /// Supported operating systems include: linux, macos, windows, freebsd,
    /// openbsd, netbsd, dragonfly, solaris, illumos, android, ios, redox,
    /// fuchsia, hermit, vxworks, aix, haiku.
    UnknownOperatingSystem,
}

impl fmt::Display for OsTypeError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::UnknownOperatingSystem => write!(f, "unknown operating system"),
        }
    }
}

#[cfg(feature = "std")]
impl std::error::Error for OsTypeError {}

/// Operating system type.
///
/// This enum provides type-safe operating system identifiers.
/// All variants are validated at construction time.
///
/// # Invariants
///
/// - All variants represent valid operating systems
/// - OS type is determined at compile time for `current()` method
///
/// # Examples
///
/// ```rust
/// use bare_types::sys::OsType;
///
/// // Use predefined constants
/// let os = OsType::LINUX;
/// assert!(os.is_unix());
///
/// // Get current OS
/// let current = OsType::current();
/// println!("Running on: {}", current);
///
/// // Convert to string representation
/// assert_eq!(OsType::LINUX.as_str(), "linux");
/// # Ok::<(), bare_types::sys::OsTypeError>(())
/// ```
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
#[non_exhaustive]
pub enum OsType {
    /// GNU/Linux distributions
    LINUX,
    /// macOS (formerly OS X)
    MACOS,
    /// Microsoft Windows
    WINDOWS,
    /// FreeBSD operating system
    FREEBSD,
    /// OpenBSD operating system
    OPENBSD,
    /// NetBSD operating system
    NETBSD,
    /// `DragonFly` BSD
    DRAGONFLY,
    /// Oracle Solaris
    SOLARIS,
    /// Illumos-based systems (`OpenIndiana`, `SmartOS`, etc.)
    ILLUMOS,
    /// Android mobile OS
    ANDROID,
    /// Apple iOS
    IOS,
    /// Redox OS (Rust-based microkernel)
    REDOX,
    /// Google Fuchsia
    FUCHSIA,
    /// `HermitCore` unikernel
    HERMIT,
    /// Wind River `VxWorks`
    VXWORKS,
    /// IBM AIX
    AIX,
    /// Haiku OS (BeOS-inspired)
    HAIKU,
}

impl OsType {
    /// Returns the current operating system (compile-time constant).
    ///
    /// This method returns the operating system the code was compiled for,
    /// not necessarily the OS of the host system (especially relevant for
    /// cross-compilation).
    ///
    /// # Examples
    ///
    /// ```rust
    /// use bare_types::sys::OsType;
    ///
    /// let os = OsType::current();
    /// println!("Compiled for: {}", os);
    /// ```
    #[must_use]
    pub const fn current() -> Self {
        #[cfg(target_os = "linux")]
        return Self::LINUX;
        #[cfg(target_os = "macos")]
        return Self::MACOS;
        #[cfg(target_os = "windows")]
        return Self::WINDOWS;
        #[cfg(target_os = "freebsd")]
        return Self::FREEBSD;
        #[cfg(target_os = "openbsd")]
        return Self::OPENBSD;
        #[cfg(target_os = "netbsd")]
        return Self::NETBSD;
        #[cfg(target_os = "dragonfly")]
        return Self::DRAGONFLY;
        #[cfg(target_os = "solaris")]
        return Self::SOLARIS;
        #[cfg(target_os = "illumos")]
        return Self::ILLUMOS;
        #[cfg(target_os = "android")]
        return Self::ANDROID;
        #[cfg(target_os = "ios")]
        return Self::IOS;
        #[cfg(target_os = "redox")]
        return Self::REDOX;
        #[cfg(target_os = "fuchsia")]
        return Self::FUCHSIA;
        #[cfg(target_os = "hermit")]
        return Self::HERMIT;
        #[cfg(target_os = "vxworks")]
        return Self::VXWORKS;
        #[cfg(target_os = "aix")]
        return Self::AIX;
        #[cfg(target_os = "haiku")]
        return Self::HAIKU;
        #[cfg(not(any(
            target_os = "linux",
            target_os = "macos",
            target_os = "windows",
            target_os = "freebsd",
            target_os = "openbsd",
            target_os = "netbsd",
            target_os = "dragonfly",
            target_os = "solaris",
            target_os = "illumos",
            target_os = "android",
            target_os = "ios",
            target_os = "redox",
            target_os = "fuchsia",
            target_os = "hermit",
            target_os = "vxworks",
            target_os = "aix",
            target_os = "haiku",
        )))]
        {
            panic!("unsupported target operating system")
        }
    }

    /// Returns the string representation of this OS.
    ///
    /// # Examples
    ///
    /// ```rust
    /// use bare_types::sys::OsType;
    ///
    /// assert_eq!(OsType::LINUX.as_str(), "linux");
    /// assert_eq!(OsType::MACOS.as_str(), "macos");
    /// assert_eq!(OsType::WINDOWS.as_str(), "windows");
    /// ```
    #[must_use]
    pub const fn as_str(&self) -> &'static str {
        match self {
            Self::LINUX => "linux",
            Self::MACOS => "macos",
            Self::WINDOWS => "windows",
            Self::FREEBSD => "freebsd",
            Self::OPENBSD => "openbsd",
            Self::NETBSD => "netbsd",
            Self::DRAGONFLY => "dragonfly",
            Self::SOLARIS => "solaris",
            Self::ILLUMOS => "illumos",
            Self::ANDROID => "android",
            Self::IOS => "ios",
            Self::REDOX => "redox",
            Self::FUCHSIA => "fuchsia",
            Self::HERMIT => "hermit",
            Self::VXWORKS => "vxworks",
            Self::AIX => "aix",
            Self::HAIKU => "haiku",
        }
    }

    /// Returns `true` if this is a Unix-like operating system.
    ///
    /// # Examples
    ///
    /// ```rust
    /// use bare_types::sys::OsType;
    ///
    /// assert!(OsType::LINUX.is_unix());
    /// assert!(OsType::MACOS.is_unix());
    /// assert!(OsType::FREEBSD.is_unix());
    /// assert!(!OsType::WINDOWS.is_unix());
    /// ```
    #[must_use]
    pub const fn is_unix(&self) -> bool {
        matches!(
            self,
            Self::LINUX
                | Self::MACOS
                | Self::FREEBSD
                | Self::OPENBSD
                | Self::NETBSD
                | Self::DRAGONFLY
                | Self::SOLARIS
                | Self::ILLUMOS
                | Self::ANDROID
                | Self::IOS
                | Self::AIX
                | Self::HAIKU
        )
    }

    /// Returns `true` if this is a BSD operating system.
    ///
    /// # Examples
    ///
    /// ```rust
    /// use bare_types::sys::OsType;
    ///
    /// assert!(OsType::FREEBSD.is_bsd());
    /// assert!(OsType::OPENBSD.is_bsd());
    /// assert!(OsType::NETBSD.is_bsd());
    /// assert!(OsType::DRAGONFLY.is_bsd());
    /// assert!(OsType::MACOS.is_bsd());
    /// assert!(!OsType::LINUX.is_bsd());
    /// assert!(!OsType::WINDOWS.is_bsd());
    /// ```
    #[must_use]
    pub const fn is_bsd(&self) -> bool {
        matches!(
            self,
            Self::FREEBSD | Self::OPENBSD | Self::NETBSD | Self::DRAGONFLY | Self::MACOS
        )
    }

    /// Returns `true` if this is Microsoft Windows.
    ///
    /// # Examples
    ///
    /// ```rust
    /// use bare_types::sys::OsType;
    ///
    /// assert!(OsType::WINDOWS.is_windows());
    /// assert!(!OsType::LINUX.is_windows());
    /// assert!(!OsType::MACOS.is_windows());
    /// ```
    #[must_use]
    pub const fn is_windows(&self) -> bool {
        matches!(self, Self::WINDOWS)
    }

    /// Returns `true` if this is a mobile operating system.
    ///
    /// # Examples
    ///
    /// ```rust
    /// use bare_types::sys::OsType;
    ///
    /// assert!(OsType::ANDROID.is_mobile());
    /// assert!(OsType::IOS.is_mobile());
    /// assert!(!OsType::LINUX.is_mobile());
    /// assert!(!OsType::WINDOWS.is_mobile());
    /// ```
    #[must_use]
    pub const fn is_mobile(&self) -> bool {
        matches!(self, Self::ANDROID | Self::IOS)
    }

    /// Returns `true` if this is a desktop operating system.
    ///
    /// # Examples
    ///
    /// ```rust
    /// use bare_types::sys::OsType;
    ///
    /// assert!(OsType::LINUX.is_desktop());
    /// assert!(OsType::MACOS.is_desktop());
    /// assert!(OsType::WINDOWS.is_desktop());
    /// assert!(!OsType::ANDROID.is_desktop());
    /// assert!(!OsType::IOS.is_desktop());
    /// ```
    #[must_use]
    pub const fn is_desktop(&self) -> bool {
        matches!(
            self,
            Self::LINUX | Self::MACOS | Self::WINDOWS | Self::FREEBSD | Self::HAIKU
        )
    }

    /// Returns `true` if this is an embedded/real-time operating system.
    ///
    /// # Examples
    ///
    /// ```rust
    /// use bare_types::sys::OsType;
    ///
    /// assert!(OsType::VXWORKS.is_embedded());
    /// assert!(!OsType::LINUX.is_embedded());
    /// ```
    #[must_use]
    pub const fn is_embedded(&self) -> bool {
        matches!(self, Self::VXWORKS)
    }

    /// Returns `true` if this is a microkernel-based operating system.
    ///
    /// # Examples
    ///
    /// ```rust
    /// use bare_types::sys::OsType;
    ///
    /// assert!(OsType::REDOX.is_microkernel());
    /// assert!(OsType::FUCHSIA.is_microkernel());
    /// assert!(!OsType::LINUX.is_microkernel());
    /// ```
    #[must_use]
    pub const fn is_microkernel(&self) -> bool {
        matches!(self, Self::REDOX | Self::FUCHSIA)
    }

    /// Returns `true` if this OS supports POSIX APIs.
    ///
    /// # Examples
    ///
    /// ```rust
    /// use bare_types::sys::OsType;
    ///
    /// assert!(OsType::LINUX.is_posix());
    /// assert!(OsType::MACOS.is_posix());
    /// assert!(!OsType::WINDOWS.is_posix());
    /// ```
    #[must_use]
    pub const fn is_posix(&self) -> bool {
        self.is_unix()
    }

    /// Returns `true` if this is a tier 1 supported Rust target.
    ///
    /// Tier 1 targets are guaranteed to work with Rust.
    ///
    /// # Examples
    ///
    /// ```rust
    /// use bare_types::sys::OsType;
    ///
    /// assert!(OsType::LINUX.is_tier1());
    /// assert!(OsType::MACOS.is_tier1());
    /// assert!(OsType::WINDOWS.is_tier1());
    /// // Tier 2/3 targets return false
    /// // assert!(!OsType::FREEBSD.is_tier1());
    /// ```
    #[must_use]
    pub const fn is_tier1(&self) -> bool {
        matches!(self, Self::LINUX | Self::MACOS | Self::WINDOWS)
    }

    /// Returns the family of this OS as a string.
    ///
    /// # Examples
    ///
    /// ```rust
    /// use bare_types::sys::OsType;
    ///
    /// assert_eq!(OsType::LINUX.family(), "unix");
    /// assert_eq!(OsType::MACOS.family(), "unix");
    /// assert_eq!(OsType::WINDOWS.family(), "windows");
    /// ```
    #[must_use]
    pub const fn family(&self) -> &'static str {
        if self.is_unix() {
            "unix"
        } else if self.is_windows() {
            "windows"
        } else {
            "unknown"
        }
    }
}

impl TryFrom<&str> for OsType {
    type Error = OsTypeError;

    fn try_from(s: &str) -> Result<Self, Self::Error> {
        s.parse()
    }
}

impl FromStr for OsType {
    type Err = OsTypeError;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s.to_lowercase().as_str() {
            "linux" => Ok(Self::LINUX),
            "macos" | "mac" | "osx" | "darwin" | "os x" => Ok(Self::MACOS),
            "windows" | "win" => Ok(Self::WINDOWS),
            "freebsd" => Ok(Self::FREEBSD),
            "openbsd" => Ok(Self::OPENBSD),
            "netbsd" => Ok(Self::NETBSD),
            "dragonfly" | "dragonfly bsd" => Ok(Self::DRAGONFLY),
            "solaris" => Ok(Self::SOLARIS),
            "illumos" => Ok(Self::ILLUMOS),
            "android" => Ok(Self::ANDROID),
            "ios" | "iphone" => Ok(Self::IOS),
            "redox" => Ok(Self::REDOX),
            "fuchsia" => Ok(Self::FUCHSIA),
            "hermit" => Ok(Self::HERMIT),
            "vxworks" => Ok(Self::VXWORKS),
            "aix" => Ok(Self::AIX),
            "haiku" => Ok(Self::HAIKU),
            _ => Err(OsTypeError::UnknownOperatingSystem),
        }
    }
}

impl fmt::Display for OsType {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_as_str() {
        assert_eq!(OsType::LINUX.as_str(), "linux");
        assert_eq!(OsType::MACOS.as_str(), "macos");
        assert_eq!(OsType::WINDOWS.as_str(), "windows");
        assert_eq!(OsType::FREEBSD.as_str(), "freebsd");
        assert_eq!(OsType::OPENBSD.as_str(), "openbsd");
        assert_eq!(OsType::NETBSD.as_str(), "netbsd");
        assert_eq!(OsType::DRAGONFLY.as_str(), "dragonfly");
        assert_eq!(OsType::SOLARIS.as_str(), "solaris");
        assert_eq!(OsType::ILLUMOS.as_str(), "illumos");
        assert_eq!(OsType::ANDROID.as_str(), "android");
        assert_eq!(OsType::IOS.as_str(), "ios");
        assert_eq!(OsType::REDOX.as_str(), "redox");
        assert_eq!(OsType::FUCHSIA.as_str(), "fuchsia");
        assert_eq!(OsType::HERMIT.as_str(), "hermit");
        assert_eq!(OsType::VXWORKS.as_str(), "vxworks");
        assert_eq!(OsType::AIX.as_str(), "aix");
        assert_eq!(OsType::HAIKU.as_str(), "haiku");
    }

    #[test]
    fn test_is_unix() {
        assert!(OsType::LINUX.is_unix());
        assert!(OsType::MACOS.is_unix());
        assert!(OsType::FREEBSD.is_unix());
        assert!(OsType::OPENBSD.is_unix());
        assert!(OsType::NETBSD.is_unix());
        assert!(OsType::DRAGONFLY.is_unix());
        assert!(OsType::SOLARIS.is_unix());
        assert!(OsType::ILLUMOS.is_unix());
        assert!(OsType::ANDROID.is_unix());
        assert!(OsType::IOS.is_unix());
        assert!(OsType::AIX.is_unix());
        assert!(OsType::HAIKU.is_unix());
        assert!(!OsType::WINDOWS.is_unix());
        assert!(!OsType::REDOX.is_unix());
        assert!(!OsType::FUCHSIA.is_unix());
    }

    #[test]
    fn test_is_bsd() {
        assert!(OsType::FREEBSD.is_bsd());
        assert!(OsType::OPENBSD.is_bsd());
        assert!(OsType::NETBSD.is_bsd());
        assert!(OsType::DRAGONFLY.is_bsd());
        assert!(OsType::MACOS.is_bsd());
        assert!(!OsType::LINUX.is_bsd());
        assert!(!OsType::WINDOWS.is_bsd());
    }

    #[test]
    fn test_is_windows() {
        assert!(OsType::WINDOWS.is_windows());
        assert!(!OsType::LINUX.is_windows());
        assert!(!OsType::MACOS.is_windows());
    }

    #[test]
    fn test_is_mobile() {
        assert!(OsType::ANDROID.is_mobile());
        assert!(OsType::IOS.is_mobile());
        assert!(!OsType::LINUX.is_mobile());
        assert!(!OsType::WINDOWS.is_mobile());
    }

    #[test]
    fn test_is_desktop() {
        assert!(OsType::LINUX.is_desktop());
        assert!(OsType::MACOS.is_desktop());
        assert!(OsType::WINDOWS.is_desktop());
        assert!(OsType::FREEBSD.is_desktop());
        assert!(OsType::HAIKU.is_desktop());
        assert!(!OsType::ANDROID.is_desktop());
        assert!(!OsType::IOS.is_desktop());
    }

    #[test]
    fn test_is_embedded() {
        assert!(OsType::VXWORKS.is_embedded());
        assert!(!OsType::LINUX.is_embedded());
    }

    #[test]
    fn test_is_microkernel() {
        assert!(OsType::REDOX.is_microkernel());
        assert!(OsType::FUCHSIA.is_microkernel());
        assert!(!OsType::LINUX.is_microkernel());
    }

    #[test]
    fn test_is_posix() {
        assert!(OsType::LINUX.is_posix());
        assert!(OsType::MACOS.is_posix());
        assert!(!OsType::WINDOWS.is_posix());
    }

    #[test]
    fn test_is_tier1() {
        assert!(OsType::LINUX.is_tier1());
        assert!(OsType::MACOS.is_tier1());
        assert!(OsType::WINDOWS.is_tier1());
        assert!(!OsType::FREEBSD.is_tier1());
    }

    #[test]
    fn test_family() {
        assert_eq!(OsType::LINUX.family(), "unix");
        assert_eq!(OsType::MACOS.family(), "unix");
        assert_eq!(OsType::WINDOWS.family(), "windows");
    }

    #[test]
    fn test_from_str() {
        assert_eq!("linux".parse::<OsType>().unwrap(), OsType::LINUX);
        assert_eq!("macos".parse::<OsType>().unwrap(), OsType::MACOS);
        assert_eq!("mac".parse::<OsType>().unwrap(), OsType::MACOS);
        assert_eq!("darwin".parse::<OsType>().unwrap(), OsType::MACOS);
        assert_eq!("windows".parse::<OsType>().unwrap(), OsType::WINDOWS);
        assert_eq!("freebsd".parse::<OsType>().unwrap(), OsType::FREEBSD);
        assert_eq!("openbsd".parse::<OsType>().unwrap(), OsType::OPENBSD);
        assert_eq!("netbsd".parse::<OsType>().unwrap(), OsType::NETBSD);
        assert_eq!("dragonfly".parse::<OsType>().unwrap(), OsType::DRAGONFLY);
        assert_eq!("solaris".parse::<OsType>().unwrap(), OsType::SOLARIS);
        assert_eq!("illumos".parse::<OsType>().unwrap(), OsType::ILLUMOS);
        assert_eq!("android".parse::<OsType>().unwrap(), OsType::ANDROID);
        assert_eq!("ios".parse::<OsType>().unwrap(), OsType::IOS);
        assert_eq!("redox".parse::<OsType>().unwrap(), OsType::REDOX);
        assert_eq!("fuchsia".parse::<OsType>().unwrap(), OsType::FUCHSIA);
        assert_eq!("hermit".parse::<OsType>().unwrap(), OsType::HERMIT);
        assert_eq!("vxworks".parse::<OsType>().unwrap(), OsType::VXWORKS);
        assert_eq!("aix".parse::<OsType>().unwrap(), OsType::AIX);
        assert_eq!("haiku".parse::<OsType>().unwrap(), OsType::HAIKU);

        // Test case insensitivity
        assert_eq!("LINUX".parse::<OsType>().unwrap(), OsType::LINUX);
        assert_eq!("Windows".parse::<OsType>().unwrap(), OsType::WINDOWS);
    }

    #[test]
    fn test_from_str_error() {
        assert!("unknown".parse::<OsType>().is_err());
        assert!("".parse::<OsType>().is_err());
    }

    #[test]
    fn test_display() {
        assert_eq!(format!("{}", OsType::LINUX), "linux");
        assert_eq!(format!("{}", OsType::MACOS), "macos");
        assert_eq!(format!("{}", OsType::WINDOWS), "windows");
    }

    #[test]
    fn test_current() {
        // Just verify it doesn't panic
        let _os = OsType::current();
    }

    #[test]
    fn test_copy() {
        let os = OsType::LINUX;
        let os2 = os;
        assert_eq!(os, os2);
    }

    #[test]
    fn test_clone() {
        let os = OsType::LINUX;
        let os2 = os.clone();
        assert_eq!(os, os2);
    }

    #[test]
    fn test_equality() {
        assert_eq!(OsType::LINUX, OsType::LINUX);
        assert_ne!(OsType::LINUX, OsType::WINDOWS);
    }

    #[test]
    fn test_ordering() {
        assert!(OsType::LINUX < OsType::ANDROID); // LINUX defined before ANDROID in enum
        assert!(OsType::LINUX < OsType::FREEBSD); // LINUX defined before FREEBSD
    }
}