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
//! System information types for building type-safe system-level applications.
//!
//! This module provides strongly-typed abstractions for common system information concepts,
//! ensuring type safety and preventing common errors in system programming.
//!
//! ## Design Rules
//!
//! All types in this module follow the core design rules, which adhere to
//! [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/):
//!
//! ### 1. Type Safety (C-NEWTYPE, C-CUSTOM-TYPE)
//!
//! - Strong types prevent mixing incompatible values
//! - Arguments convey meaning through types, not `bool` or `Option`
//! - All validation performed at construction time
//! - No runtime errors from invalid states
//! - Invalid states are unrepresentable
//!
//! ### 2. Zero-Cost Abstractions
//!
//! - No runtime overhead compared to using primitive types
//! - All validation happens at compile time or construction
//! - Subsequent operations have zero cost
//! - Use `#[repr(transparent)]` for newtypes over primitive types
//!
//! ### 3. Compile-Time Constants
//!
//! - `Arch::current()` and `OsType::current()` return compile-time constants
//! - These reflect the target platform, not runtime detection
//! - Cross-compilation safe
//!
//! ### 4. Composability (C-COMMON-TRAITS, C-CONV-TRAITS)
//!
//! All types implement standard traits:
//! - **Common traits** (C-COMMON-TRAITS):
//! - `Debug` for debugging
//! - `Clone` for copying
//! - `Display` for formatting
//! - `Hash` for use in hash maps
//! - `Eq` and `PartialEq` for equality
//! - `Ord` and `PartialOrd` for ordering (where applicable)
//! - **Conversion traits** (C-CONV-TRAITS):
//! - `FromStr` for parsing from strings
//! - `From` for infallible conversions
//! - `TryFrom` for fallible conversions
//!
//! ### 5. Security (C-SEND-SYNC, C-GOOD-ERR)
//!
//! - Types are `Send` and `Sync` where possible (C-SEND-SYNC)
//! - Error types implement `std::error::Error`, `Send`, `Sync` (C-GOOD-ERR)
//! - No unsafe code allowed
//!
//! ### 6. Explicit Over Implicit (C-DEREF, C-CTOR)
//!
//! - Only smart pointers implement `Deref` and `DerefMut` (C-DEREF)
//! - Constructors are static, inherent methods (C-CTOR)
//! - Prefer explicit constructors
//! - Clear, readable code over clever abstractions
//!
//! ## Types
//!
//! This module includes types for:
//!
//! - **Architecture**: CPU architecture enumeration (`Arch`)
//! - **Operating System**: OS type enumeration (`OsType`)
//! - **OS Version**: Version numbers for OS releases (`OsVersion`)
//! - **Kernel Version**: Linux/Unix kernel versions with release strings (`KernelVersion`)
//! - **System Hostname**: System hostname with RFC 1123 validation (`Hostname`)
//! - **System Username**: POSIX-compliant system username (`Username`)
//! - **OS Distribution**: OS distribution name with family detection (`Distro`)
//! - **Process ID**: Type-safe process identifier (`Pid`)
//! - **File Descriptor**: Type-safe file descriptor (`Fd`)
//!
//! Note: `Hostname` is re-exported from the `net` module as it uses the same
//! RFC 1123 validation rules for both network and system contexts.
//!
//! ## Features
//!
//! This module requires `sys` feature to be enabled.
//!
//! ```toml
//! [dependencies]
//! bare-types = { version = "0.1", features = ["sys"] }
//! ```
//!
//! ## `no_std` Support
//!
//! This module is fully `no_std` compatible. All types are built on `core`
//! and do not require the standard library.
//!
//! To use in a `no_std` environment:
//!
//! ```toml
//! [dependencies]
//! bare-types = { version = "0.1", default-features = false, features = ["sys"] }
//! ```
//!
//! The `std` feature can be optionally enabled for `std::error::Error` implementations.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
// Re-export Hostname from net module for sys context
pub use crate;