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
use String;
use crate::;
/// Get the CPU Architecture.
/// Get the user's account name; usually just the username, but may include an
/// account server hostname.
///
/// If you don't want the account server hostname, use [`username()`].
///
/// Example: `username@example.com`
/// Get the user's account name; usually just the username, but may
/// include an account server hostname.
///
/// If you don't want the account server hostname, use [`username()`].
///
/// Example: `username@example.com`
/// Get the user's username.
///
/// On unix-systems this differs from [`realname()`] most notably in that spaces
/// are not allowed in the username.
/// Get the user's username.
///
/// On unix-systems this differs from [`realname_os()`] most notably in that
/// spaces are not allowed in the username.
/// Get the user's real (full) name.
/// Get the user's real (full) name.
/// Get the host device's hostname.
///
/// Usually hostnames are case-insensitive, but it's not a hard requirement.
///
/// # Platform-Specific Character Limitations
///
/// ## Unix/Linux/BSD
/// - **Maximum length**: 255 bytes (excluding null terminator)
/// - **Encoding**: Must be valid UTF-8
/// - **Characters**: Typically follows RFC 952/1123 DNS hostname rules:
/// - Alphanumeric characters (a-z, A-Z, 0-9)
/// - Hyphens (-), but not at start or end
/// - Note: POSIX allows any character except null and newline, but network
/// hostnames should follow DNS rules for interoperability
///
/// ## Windows
/// - **Maximum length**: 63 characters for DNS hostname (per label)
/// - **Encoding**: UTF-16 (converted to UTF-8 String)
/// - **Characters**: Follows DNS hostname rules (RFC 1123):
/// - Alphanumeric characters (a-z, A-Z, 0-9)
/// - Hyphens (-), but not at start or end
///
/// ## Redox
/// - Reads from `/etc/hostname` file
/// - First line of file is used as hostname
/// - No inherent character limitations beyond file system
///
/// ## Web (WASM)
/// - Returns the document's domain name
/// - Follows DNS hostname rules as enforced by browsers
/// - Must be valid UTF-8
///
/// ## Other Platforms
/// - WASI: Returns system hostname or defaults to "localhost"
/// - Default: Returns "localhost" for unsupported platforms
///
/// # Notes
/// For maximum compatibility across all platforms and network protocols,
/// hostnames should:
/// - Be 63 characters or less
/// - Contain only ASCII alphanumeric characters and hyphens
/// - Not start or end with a hyphen
/// - Be case-insensitive (though case may be preserved)
/// Get the device name (also known as "Pretty Name").
///
/// Often used to identify device for bluetooth pairing.
/// Get the device name (also known as "Pretty Name").
///
/// Often used to identify device for bluetooth pairing.
/// Get the name of the operating system distribution and (possibly) version.
///
/// Example: "Windows 10" or "Fedora 26 (Workstation Edition)"
/// Get the desktop environment (if any).
///
/// Example: "gnome" or "windows"
///
/// Returns `None` if a desktop environment is not available (for example in a
/// TTY or over SSH)
/// Get the platform.
/// Get the user's preferred language(s).
///
/// Returned as an instance of [`LanguagePreferences`]