2019-02-11 20:36:45 +00:00
|
|
|
//! Platform-specific extensions to `std` for Unix platforms.
|
2015-04-16 06:21:13 +00:00
|
|
|
//!
|
2017-10-31 09:41:10 +00:00
|
|
|
//! Provides access to platform-level information on Unix platforms, and
|
|
|
|
//! exposes Unix-specific functions that would otherwise be inappropriate as
|
|
|
|
//! part of the core `std` library.
|
|
|
|
//!
|
|
|
|
//! It exposes more ways to deal with platform-specific strings (`OsStr`,
|
|
|
|
//! `OsString`), allows to set permissions more granularly, extract low-level
|
|
|
|
//! file descriptors from files and sockets, and has platform-specific helpers
|
|
|
|
//! for spawning processes.
|
2015-04-16 06:21:13 +00:00
|
|
|
//!
|
2017-08-24 15:33:36 +00:00
|
|
|
//! # Examples
|
2015-04-16 06:21:13 +00:00
|
|
|
//!
|
|
|
|
//! ```no_run
|
|
|
|
//! use std::fs::File;
|
|
|
|
//! use std::os::unix::prelude::*;
|
|
|
|
//!
|
2019-11-24 12:56:37 +00:00
|
|
|
//! fn main() -> std::io::Result<()> {
|
2019-11-12 21:07:39 +00:00
|
|
|
//! let f = File::create("foo.txt")?;
|
2015-04-16 06:21:13 +00:00
|
|
|
//! let fd = f.as_raw_fd();
|
|
|
|
//!
|
|
|
|
//! // use fd with native unix bindings
|
2019-11-24 12:56:37 +00:00
|
|
|
//!
|
|
|
|
//! Ok(())
|
2015-04-16 06:21:13 +00:00
|
|
|
//! }
|
|
|
|
//! ```
|
|
|
|
|
|
|
|
#![stable(feature = "rust1", since = "1.0.0")]
|
2017-08-05 06:39:46 +00:00
|
|
|
#![doc(cfg(unix))]
|
2018-06-15 08:00:57 +00:00
|
|
|
#![allow(missing_docs)]
|
2015-04-16 06:21:13 +00:00
|
|
|
|
|
|
|
pub mod ffi;
|
|
|
|
pub mod fs;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub mod io;
|
|
|
|
pub mod net;
|
2015-04-16 06:21:13 +00:00
|
|
|
pub mod process;
|
|
|
|
pub mod raw;
|
2015-12-04 02:58:00 +00:00
|
|
|
pub mod thread;
|
2015-04-16 06:21:13 +00:00
|
|
|
|
2020-08-04 10:18:13 +00:00
|
|
|
#[unstable(feature = "peer_credentials_unix_socket", issue = "42839", reason = "unstable")]
|
|
|
|
#[cfg(any(
|
|
|
|
target_os = "android",
|
|
|
|
target_os = "linux",
|
|
|
|
target_os = "dragonfly",
|
|
|
|
target_os = "freebsd",
|
|
|
|
target_os = "ios",
|
|
|
|
target_os = "macos",
|
|
|
|
target_os = "openbsd"
|
|
|
|
))]
|
|
|
|
pub mod ucred;
|
|
|
|
|
2015-04-16 06:21:13 +00:00
|
|
|
/// A prelude for conveniently writing platform-specific code.
|
|
|
|
///
|
|
|
|
/// Includes all extension traits, and some important type definitions.
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
pub mod prelude {
|
2019-12-22 22:42:04 +00:00
|
|
|
#[doc(no_inline)]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
2015-04-16 06:21:13 +00:00
|
|
|
pub use super::ffi::{OsStrExt, OsStringExt};
|
2019-12-22 22:42:04 +00:00
|
|
|
#[doc(no_inline)]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
2016-04-07 17:42:53 +00:00
|
|
|
pub use super::fs::DirEntryExt;
|
2019-12-22 22:42:04 +00:00
|
|
|
#[doc(no_inline)]
|
|
|
|
#[stable(feature = "file_offset", since = "1.15.0")]
|
2016-08-15 23:11:33 +00:00
|
|
|
pub use super::fs::FileExt;
|
2019-12-22 22:42:04 +00:00
|
|
|
#[doc(no_inline)]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
pub use super::fs::{FileTypeExt, MetadataExt, OpenOptionsExt, PermissionsExt};
|
|
|
|
#[doc(no_inline)]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
pub use super::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
|
|
|
|
#[doc(no_inline)]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
2015-04-16 06:21:13 +00:00
|
|
|
pub use super::process::{CommandExt, ExitStatusExt};
|
2019-12-22 22:42:04 +00:00
|
|
|
#[doc(no_inline)]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
pub use super::thread::JoinHandleExt;
|
2015-04-16 06:21:13 +00:00
|
|
|
}
|