]> git.lizzy.rs Git - rust.git/blob - library/std/src/sys/unix/ext/mod.rs
Rollup merge of #76728 - jyn514:rustdoc-extern-crate, r=ehuss
[rust.git] / library / std / src / sys / unix / ext / mod.rs
1 //! Platform-specific extensions to `std` for Unix platforms.
2 //!
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.
6 //!
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.
11 //!
12 //! # Examples
13 //!
14 //! ```no_run
15 //! use std::fs::File;
16 //! use std::os::unix::prelude::*;
17 //!
18 //! fn main() -> std::io::Result<()> {
19 //!     let f = File::create("foo.txt")?;
20 //!     let fd = f.as_raw_fd();
21 //!
22 //!     // use fd with native unix bindings
23 //!
24 //!     Ok(())
25 //! }
26 //! ```
27
28 #![stable(feature = "rust1", since = "1.0.0")]
29 #![doc(cfg(unix))]
30 #![allow(missing_docs)]
31
32 pub mod ffi;
33 pub mod fs;
34 pub mod io;
35 pub mod net;
36 pub mod process;
37 pub mod raw;
38 pub mod thread;
39
40 #[unstable(feature = "peer_credentials_unix_socket", issue = "42839", reason = "unstable")]
41 #[cfg(any(
42     target_os = "android",
43     target_os = "linux",
44     target_os = "dragonfly",
45     target_os = "freebsd",
46     target_os = "ios",
47     target_os = "macos",
48     target_os = "openbsd"
49 ))]
50 pub mod ucred;
51
52 /// A prelude for conveniently writing platform-specific code.
53 ///
54 /// Includes all extension traits, and some important type definitions.
55 #[stable(feature = "rust1", since = "1.0.0")]
56 pub mod prelude {
57     #[doc(no_inline)]
58     #[stable(feature = "rust1", since = "1.0.0")]
59     pub use super::ffi::{OsStrExt, OsStringExt};
60     #[doc(no_inline)]
61     #[stable(feature = "rust1", since = "1.0.0")]
62     pub use super::fs::DirEntryExt;
63     #[doc(no_inline)]
64     #[stable(feature = "file_offset", since = "1.15.0")]
65     pub use super::fs::FileExt;
66     #[doc(no_inline)]
67     #[stable(feature = "rust1", since = "1.0.0")]
68     pub use super::fs::{FileTypeExt, MetadataExt, OpenOptionsExt, PermissionsExt};
69     #[doc(no_inline)]
70     #[stable(feature = "rust1", since = "1.0.0")]
71     pub use super::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
72     #[doc(no_inline)]
73     #[stable(feature = "rust1", since = "1.0.0")]
74     pub use super::process::{CommandExt, ExitStatusExt};
75     #[doc(no_inline)]
76     #[stable(feature = "rust1", since = "1.0.0")]
77     pub use super::thread::JoinHandleExt;
78 }