]>
Commit | Line | Data |
---|---|---|
9fa01778 | 1 | //! Platform-specific extensions to `std` for Unix platforms. |
d9579d0f | 2 | //! |
abe05a73 XL |
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. | |
d9579d0f | 11 | //! |
3b2f2976 | 12 | //! # Examples |
d9579d0f AL |
13 | //! |
14 | //! ```no_run | |
15 | //! use std::fs::File; | |
16 | //! use std::os::unix::prelude::*; | |
17 | //! | |
60c5eb7d XL |
18 | //! fn main() -> std::io::Result<()> { |
19 | //! let f = File::create("foo.txt")?; | |
d9579d0f AL |
20 | //! let fd = f.as_raw_fd(); |
21 | //! | |
22 | //! // use fd with native unix bindings | |
60c5eb7d XL |
23 | //! |
24 | //! Ok(()) | |
d9579d0f AL |
25 | //! } |
26 | //! ``` | |
27 | ||
28 | #![stable(feature = "rust1", since = "1.0.0")] | |
3b2f2976 | 29 | #![doc(cfg(unix))] |
94b46f34 | 30 | #![allow(missing_docs)] |
d9579d0f AL |
31 | |
32 | pub mod io; | |
33 | pub mod ffi; | |
34 | pub mod fs; | |
35 | pub mod process; | |
36 | pub mod raw; | |
92a42be0 | 37 | pub mod thread; |
54a0048b | 38 | pub mod net; |
d9579d0f AL |
39 | |
40 | /// A prelude for conveniently writing platform-specific code. | |
41 | /// | |
42 | /// Includes all extension traits, and some important type definitions. | |
43 | #[stable(feature = "rust1", since = "1.0.0")] | |
44 | pub mod prelude { | |
92a42be0 | 45 | #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")] |
e9174d1e | 46 | pub use super::io::{RawFd, AsRawFd, FromRawFd, IntoRawFd}; |
d9579d0f AL |
47 | #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")] |
48 | pub use super::ffi::{OsStrExt, OsStringExt}; | |
92a42be0 | 49 | #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")] |
c1a9b12d | 50 | pub use super::fs::{PermissionsExt, OpenOptionsExt, MetadataExt, FileTypeExt}; |
92a42be0 | 51 | #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")] |
54a0048b | 52 | pub use super::fs::DirEntryExt; |
476ff2be | 53 | #[doc(no_inline)] #[stable(feature = "file_offset", since = "1.15.0")] |
c30ab7b3 | 54 | pub use super::fs::FileExt; |
54a0048b SL |
55 | #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")] |
56 | pub use super::thread::JoinHandleExt; | |
d9579d0f AL |
57 | #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")] |
58 | pub use super::process::{CommandExt, ExitStatusExt}; | |
59 | } |