1 //! Platform-specific extensions to `std` for Unix platforms.
3 //! Provides access to platform-level information on Unix platforms, and
4 //! exposes Unix-specific functions that would otherwise be inappropriate as
5 //! part of the core `std` library.
7 //! It exposes more ways to deal with platform-specific strings (`OsStr`,
8 //! `OsString`), allows to set permissions more granularly, extract low-level
9 //! file descriptors from files and sockets, and has platform-specific helpers
10 //! for spawning processes.
15 //! use std::fs::File;
16 //! use std::os::unix::prelude::*;
18 //! fn main() -> std::io::Result<()> {
19 //! let f = File::create("foo.txt")?;
20 //! let fd = f.as_raw_fd();
22 //! // use fd with native unix bindings
28 #![stable(feature = "rust1", since = "1.0.0")]
31 // Use linux as the default platform when documenting on other platforms like Windows
33 use crate::os::linux as platform;
37 #[cfg(target_os = "android")]
38 pub use crate::os::android::*;
39 #[cfg(target_os = "dragonfly")]
40 pub use crate::os::dragonfly::*;
41 #[cfg(target_os = "emscripten")]
42 pub use crate::os::emscripten::*;
43 #[cfg(target_os = "espidf")]
44 pub use crate::os::espidf::*;
45 #[cfg(target_os = "freebsd")]
46 pub use crate::os::freebsd::*;
47 #[cfg(target_os = "fuchsia")]
48 pub use crate::os::fuchsia::*;
49 #[cfg(target_os = "haiku")]
50 pub use crate::os::haiku::*;
51 #[cfg(target_os = "illumos")]
52 pub use crate::os::illumos::*;
53 #[cfg(target_os = "ios")]
54 pub use crate::os::ios::*;
55 #[cfg(any(target_os = "linux", target_os = "l4re"))]
56 pub use crate::os::linux::*;
57 #[cfg(target_os = "macos")]
58 pub use crate::os::macos::*;
59 #[cfg(target_os = "netbsd")]
60 pub use crate::os::netbsd::*;
61 #[cfg(target_os = "openbsd")]
62 pub use crate::os::openbsd::*;
63 #[cfg(target_os = "redox")]
64 pub use crate::os::redox::*;
65 #[cfg(target_os = "solaris")]
66 pub use crate::os::solaris::*;
67 #[cfg(target_os = "vxworks")]
68 pub use crate::os::vxworks::*;
79 #[unstable(feature = "peer_credentials_unix_socket", issue = "42839", reason = "unstable")]
81 target_os = "android",
83 target_os = "dragonfly",
84 target_os = "freebsd",
92 /// A prelude for conveniently writing platform-specific code.
94 /// Includes all extension traits, and some important type definitions.
95 #[stable(feature = "rust1", since = "1.0.0")]
98 #[stable(feature = "rust1", since = "1.0.0")]
99 pub use super::ffi::{OsStrExt, OsStringExt};
101 #[stable(feature = "rust1", since = "1.0.0")]
102 pub use super::fs::DirEntryExt;
104 #[stable(feature = "file_offset", since = "1.15.0")]
105 pub use super::fs::FileExt;
107 #[stable(feature = "rust1", since = "1.0.0")]
108 pub use super::fs::{FileTypeExt, MetadataExt, OpenOptionsExt, PermissionsExt};
110 #[stable(feature = "rust1", since = "1.0.0")]
111 pub use super::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
113 #[stable(feature = "rust1", since = "1.0.0")]
114 pub use super::process::{CommandExt, ExitStatusExt};
116 #[stable(feature = "rust1", since = "1.0.0")]
117 pub use super::thread::JoinHandleExt;