Debian Codegraph @

src/lib_impl.rs

raw symbols SCIP
1 // "plumbing" setup and connections for `lib.rs`
2
3 #![warn(unused_results)] // enable warnings for unused results
4
5 #[cfg(target_os = "windows")]
6 use std::path::Path;
7 #[cfg(target_os = "windows")]
8 use std::path::PathBuf;
9
10 //=== types
11
12 /// Standard thread-safe error type
13 pub type ThreadSafeStdError = dyn std::error::Error + Send + Sync;
14 /// Standard thread-safe error type (boxed to allow translation for any `std::error::Error` type)
15 pub type BoxedThreadSafeStdError = Box<ThreadSafeStdError>;
16
17 /// A slice of a path string
18 /// (akin to [`str`]; aka/equivalent to [`Path`]).
19 #[cfg(target_os = "windows")]
20 type PathStr = Path;
21 /// An owned, mutable path string
22 /// (akin to [`String`]; aka/equivalent to [`PathBuf`]).
23 #[cfg(target_os = "windows")]
24 type PathString = PathBuf;
25
26 //=== platform-specific const
27
28 // HOST_OS_NAME * ref: [`uname` info](https://en.wikipedia.org/wiki/Uname)
29 const HOST_OS_NAME: &str = if cfg!(all(
30 target_os = "linux",
31 any(target_env = "gnu", target_env = "")
32 )) {
33 "GNU/Linux"
34 } else if cfg!(all(
35 target_os = "linux",
36 not(any(target_env = "gnu", target_env = ""))
37 )) {
38 "Linux"
39 } else if cfg!(target_os = "android") {
40 "Android"
41 } else if cfg!(target_os = "windows") {
42 "MS/Windows" // prior art == `busybox`
43 } else if cfg!(target_os = "freebsd") {
44 "FreeBSD"
45 } else if cfg!(target_os = "netbsd") {
46 "NetBSD"
47 } else if cfg!(target_os = "openbsd") {
48 "OpenBSD"
49 } else if cfg!(target_vendor = "apple") {
50 "Darwin"
51 } else if cfg!(target_os = "fuchsia") {
52 "Fuchsia"
53 } else if cfg!(target_os = "redox") {
54 "Redox"
55 } else if cfg!(target_os = "illumos") {
56 "illumos"
57 } else if cfg!(target_os = "solaris") {
58 "solaris"
59 } else {
60 "unknown"
61 };
62
63 //=== platform-specific module code
64
65 #[cfg(unix)]
66 #[path = "platform/unix.rs"]
67 mod target;
68 #[cfg(windows)]
69 #[path = "platform/windows.rs"]
70 mod target;
71 #[cfg(not(any(unix, windows)))]
72 #[path = "platform/unknown.rs"]
73 mod target;
74
75 pub use target::*;