From 5f5b7d4d7a76575673b57e685c13ba2c52c4183e Mon Sep 17 00:00:00 2001 From: Vincent Dagonneau Date: Thu, 19 Mar 2020 11:40:53 +0100 Subject: feature-gate most Nix functions Using features reduces build time and size for consumer crates. By default all features are enabled. --- src/pty.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/pty.rs') diff --git a/src/pty.rs b/src/pty.rs index facc9aaf..a104a69c 100644 --- a/src/pty.rs +++ b/src/pty.rs @@ -9,8 +9,9 @@ use std::mem; use std::os::unix::prelude::*; use crate::sys::termios::Termios; -use crate::unistd::{self, ForkResult, Pid}; -use crate::{Result, fcntl}; +#[cfg(feature = "process")] +use crate::unistd::{ForkResult, Pid}; +use crate::{Result, fcntl, unistd}; use crate::errno::Errno; /// Representation of a master/slave pty pair @@ -25,6 +26,8 @@ pub struct OpenptyResult { pub slave: RawFd, } +feature! { +#![feature = "process"] /// Representation of a master with a forked pty /// /// This is returned by `forkpty`. Note that this type does *not* implement `Drop`, so the user @@ -36,6 +39,7 @@ pub struct ForkptyResult { /// Metadata about forked process pub fork_result: ForkResult, } +} /// Representation of the Master device in a master/slave pty pair @@ -188,6 +192,7 @@ pub unsafe fn ptsname(fd: &PtyMaster) -> Result { /// This value is useful for opening the slave ptty once the master has already been opened with /// `posix_openpt()`. #[cfg(any(target_os = "android", target_os = "linux"))] +#[cfg_attr(docsrs, doc(cfg(all())))] #[inline] pub fn ptsname_r(fd: &PtyMaster) -> Result { let mut name_buf = Vec::::with_capacity(64); @@ -294,6 +299,8 @@ pub fn openpty<'a, 'b, T: Into>, U: Into } } +feature! { +#![feature = "process"] /// Create a new pseudoterminal, returning the master file descriptor and forked pid. /// in `ForkptyResult` /// (see [`forkpty`](https://man7.org/linux/man-pages/man3/forkpty.3.html)). @@ -346,3 +353,4 @@ pub unsafe fn forkpty<'a, 'b, T: Into>, U: Into