use std::ffi::OsStr;
use std::io;
use std::os::unix::process::CommandExt as _;
use cfg_if::cfg_if;
use crate::Command;
cfg_if! {
if #[cfg(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon", target_os = "vita"))] {
type UserId = u16;
type GroupId = u16;
} else if #[cfg(any(target_os = "nto", target_os = "qnx"))] {
type UserId = i32;
type GroupId = i32;
} else {
type UserId = u32;
type GroupId = u32;
}
}
pub trait CommandExt: crate::sealed::Sealed {
fn uid(&mut self, id: UserId) -> &mut Command;
fn gid(&mut self, id: GroupId) -> &mut Command;
fn exec(&mut self) -> io::Error;
fn arg0<S>(&mut self, arg: S) -> &mut Command
where
S: AsRef<OsStr>;
}
impl crate::sealed::Sealed for Command {}
impl CommandExt for Command {
fn uid(&mut self, id: UserId) -> &mut Command {
self.inner.uid(id);
self
}
fn gid(&mut self, id: GroupId) -> &mut Command {
self.inner.gid(id);
self
}
fn exec(&mut self) -> io::Error {
self.inner.exec()
}
fn arg0<S>(&mut self, arg: S) -> &mut Command
where
S: AsRef<OsStr>,
{
self.inner.arg0(arg);
self
}
}