diff --git a/src/generic_wrap.rs b/src/generic_wrap.rs index a2fe52a..d6e5ed4 100644 --- a/src/generic_wrap.rs +++ b/src/generic_wrap.rs @@ -4,24 +4,24 @@ )] macro_rules! Wrap { - ($name:ident, $command:ty, $wrapper:ident, $child:ty, $childer:ident, $first_child_wrapper:expr) => { + ($command:ty, $child:ty, $childer:ident, $first_child_wrapper:expr) => { /// A wrapper around a `Command` that allows for additional functionality to be added. /// /// This is the core type of the `process-wrap` crate. It is a wrapper around a #[doc = concat!("[`", stringify!($command), "`].")] #[derive(Debug)] - pub struct $name { + pub struct CommandWrap { command: $command, - wrappers: ::indexmap::IndexMap<::std::any::TypeId, Box>, + wrappers: ::indexmap::IndexMap<::std::any::TypeId, Box>, } - impl $name { + impl CommandWrap { /// Create from a program name and a closure to configure the command. /// /// This is a convenience method that creates a new `Command` and then calls the closure /// to configure it. The `Command` is then wrapped and returned. /// - #[doc = concat!("Alternatively, use `From`/`Into` to convert a [`", stringify!($command),"`] to a [`", stringify!($name), "`].")] + #[doc = concat!("Alternatively, use `From`/`Into` to convert a [`", stringify!($command),"`] to a [`", stringify!(CommandWrap), "`].")] pub fn with_new( program: impl AsRef<::std::ffi::OsStr>, init: impl FnOnce(&mut $command), @@ -60,7 +60,7 @@ macro_rules! Wrap { /// will be silently discarded. /// /// Returns `&mut self` for chaining. - pub fn wrap(&mut self, wrapper: W) -> &mut Self { + pub fn wrap(&mut self, wrapper: W) -> &mut Self { let typeid = ::std::any::TypeId::of::(); let mut wrapper = Some(Box::new(wrapper)); let extant = self @@ -79,7 +79,7 @@ macro_rules! Wrap { fn spawn_inner( &self, command: &mut $command, - wrappers: &mut ::indexmap::IndexMap<::std::any::TypeId, Box>, + wrappers: &mut ::indexmap::IndexMap<::std::any::TypeId, Box>, ) -> ::std::io::Result> { for (id, wrapper) in wrappers.iter_mut() { #[cfg(feature = "tracing")] @@ -127,7 +127,7 @@ macro_rules! Wrap { } /// Check if a wrapper of a given type is present. - pub fn has_wrap(&self) -> bool { + pub fn has_wrap(&self) -> bool { let typeid = ::std::any::TypeId::of::(); self.wrappers.contains_key(&typeid) } @@ -139,7 +139,7 @@ macro_rules! Wrap { /// /// Returns `None` if the wrapper is not present. To merely check if a wrapper is /// present, use `has_wrap` instead. - pub fn get_wrap(&self) -> Option<&W> { + pub fn get_wrap(&self) -> Option<&W> { let typeid = ::std::any::TypeId::of::(); self.wrappers.get(&typeid).map(|w| { let w_any = w as &dyn ::std::any::Any; @@ -150,7 +150,7 @@ macro_rules! Wrap { } } - impl From for $name { + impl From for CommandWrap { fn from(command: $command) -> Self { Self { command, @@ -169,8 +169,8 @@ macro_rules! Wrap { /// ```rust,ignore /// #[derive(Debug)] /// pub struct YourWrapper; - #[doc = concat!("impl ", stringify!($wrapper), " for YourWrapper {}\n```")] - pub trait $wrapper: ::std::fmt::Debug + Send + Sync { + #[doc = concat!("impl ", stringify!(CommandWrapper), " for YourWrapper {}\n```")] + pub trait CommandWrapper: ::std::fmt::Debug + Send + Sync { /// Called on a first instance if a second of the same type is added. /// /// Only one of a wrapper type can exist within a Wrap at a time. The default behaviour @@ -184,7 +184,7 @@ macro_rules! Wrap { /// downcasting fails, instead of using unchecked downcasting and unleashing UB. /// /// Default impl: no-op. - fn extend(&mut self, _other: Box) {} + fn extend(&mut self, _other: Box) {} /// Called before the command is spawned, to mutate it as needed. /// @@ -194,7 +194,7 @@ macro_rules! Wrap { /// `CreationFlags` on Windows works along with `JobObject`. /// /// Defaut impl: no-op. - fn pre_spawn(&mut self, _command: &mut $command, _core: &$name) -> Result<()> { + fn pre_spawn(&mut self, _command: &mut $command, _core: &CommandWrap) -> Result<()> { Ok(()) } @@ -204,7 +204,7 @@ macro_rules! Wrap { /// how `CreationFlags` on Windows works along with `JobObject`. /// /// Default: no-op. - fn post_spawn(&mut self, _command: &mut $command, _child: &mut $child, _core: &$name) -> Result<()> { + fn post_spawn(&mut self, _command: &mut $command, _child: &mut $child, _core: &CommandWrap) -> Result<()> { Ok(()) } @@ -222,7 +222,7 @@ macro_rules! Wrap { fn wrap_child( &mut self, child: Box, - _core: &$name, + _core: &CommandWrap, ) -> Result> { Ok(child) } diff --git a/src/lib.rs b/src/lib.rs index eddc115..ed80d14 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,7 +11,7 @@ //! # fn main() -> std::io::Result<()> { //! use process_wrap::std::*; //! -//! let mut command = StdCommandWrap::with_new("watch", |command| { command.arg("ls"); }); +//! let mut command = CommandWrap::with_new("watch", |command| { command.arg("ls"); }); //! #[cfg(unix)] { command.wrap(ProcessGroup::leader()); } //! #[cfg(windows)] { command.wrap(JobObject); } //! let mut child = command.spawn()?; @@ -36,7 +36,7 @@ //! //! # Usage //! -//! The core API is [`StdCommandWrap`](std::StdCommandWrap) and [`TokioCommandWrap`](tokio::TokioCommandWrap), +//! The core API is [`CommandWrap`](std::CommandWrap) and [`CommandWrap`](tokio::CommandWrap), //! which can be constructed either directly from an existing `process::Command`: //! //! ```rust @@ -44,7 +44,7 @@ //! use std::process::Command; //! let mut command = Command::new("ls"); //! command.arg("-l"); -//! let mut command = StdCommandWrap::from(command); +//! let mut command = CommandWrap::from(command); //! #[cfg(unix)] { command.wrap(ProcessGroup::leader()); } //! #[cfg(windows)] { command.wrap(JobObject); } //! ``` @@ -53,7 +53,7 @@ //! //! ```rust //! use process_wrap::std::*; -//! let mut command = StdCommandWrap::with_new("ls", |command| { command.arg("-l"); }); +//! let mut command = CommandWrap::with_new("ls", |command| { command.arg("-l"); }); //! #[cfg(unix)] { command.wrap(ProcessGroup::leader()); } //! #[cfg(windows)] { command.wrap(JobObject); } //! ``` @@ -62,7 +62,7 @@ //! //! ```rust //! use process_wrap::std::*; -//! StdCommandWrap::with_new("ls", |command| { command.arg("-l"); }) +//! CommandWrap::with_new("ls", |command| { command.arg("-l"); }) //! .wrap(ProcessGroup::leader()); //! ``` //! @@ -89,7 +89,7 @@ //! //! ```rust //! use process_wrap::tokio::*; -//! let mut command = TokioCommandWrap::with_new("ls", |command| { command.arg("-l"); }); +//! let mut command = CommandWrap::with_new("ls", |command| { command.arg("-l"); }); //! command.wrap(KillOnDrop); //! ``` //! @@ -97,7 +97,7 @@ //! //! ```rust,ignore //! use process_wrap::std::*; -//! let mut command = StdCommandWrap::with_new("ls", |command| { command.arg("-l"); }); +//! let mut command = CommandWrap::with_new("ls", |command| { command.arg("-l"); }); //! command.wrap(CreationFlags(CREATE_NO_WINDOW)); //! ``` //! @@ -112,8 +112,8 @@ //! underlying APIs. Of course you can (and should) re-use/share code wherever possible if //! implementing both. //! -//! At minimum, you must implement [`StdCommandWrapper`](crate::std::StdCommandWrapper) and/or -//! [`TokioCommandWrapper`](crate::tokio::TokioCommandWrapper). These provide the same functionality +//! At minimum, you must implement [`CommandWrapper`](crate::std::CommandWrapper) and/or +//! [`CommandWrapper`](crate::tokio::CommandWrapper). These provide the same functionality //! (and indeed internally are generated using a common macro), but differ in the exact types used. //! Here's the most basic impl (shown for Tokio): //! @@ -121,27 +121,27 @@ //! use process_wrap::tokio::*; //! #[derive(Debug)] //! pub struct YourWrapper; -//! impl TokioCommandWrapper for YourWrapper {} +//! impl CommandWrapper for YourWrapper {} //! ``` //! //! The trait provides extension or hook points into the lifecycle of a `Command`: //! -//! - **`fn extend(&mut self, other: Box)`** is called if +//! - **`fn extend(&mut self, other: Box)`** is called if //! `.wrap(YourWrapper)` is done twice. Only one of a wrapper type can exist, so this gives the //! opportunity to incorporate all or part of the second wrapper instance into the first. By //! default, this does nothing (ie only the first registered wrapper instance of a type applies). //! -//! - **`fn pre_spawn(&mut self, command: &mut Command, core: &TokioCommandWrap)`** is called before +//! - **`fn pre_spawn(&mut self, command: &mut Command, core: &CommandWrap)`** is called before //! the command is spawned, and gives mutable access to it. It also gives mutable access to the //! wrapper instance, so state can be stored if needed. The `core` reference gives access to data //! from other wrappers; for example, that's how `CreationFlags` on Windows works along with //! `JobObject`. By default does nothing. //! -//! - **`fn post_spawn(&mut self, child: &mut tokio::process::Child, core: &TokioCommandWrap)`** is +//! - **`fn post_spawn(&mut self, child: &mut tokio::process::Child, core: &CommandWrap)`** is //! called after spawn, and should be used for any necessary cleanups. It is offered for //! completeness but is expected to be less used than `wrap_child()`. By default does nothing. //! -//! - **`fn wrap_child(&mut self, child: Box, core: &TokioCommandWrap)`** is +//! - **`fn wrap_child(&mut self, child: Box, core: &CommandWrap)`** is //! called after all `post_spawn()`s have run. If your wrapper needs to override the methods on //! Child, then it should create an instance of its own type implementing `TokioChildWrapper` and //! return it here. Child wraps are _in order_: you may end up with a `Foo(Bar(Child))` or a @@ -157,31 +157,31 @@ //! in. //! //! ```rust -//! # use process_wrap::std::{StdCommandWrap, StdCommandWrapper}; +//! # use process_wrap::std::{CommandWrap, CommandWrapper}; //! # use std::{fs::File, io, path::PathBuf, process::Command, thread}; //! #[derive(Debug)] //! struct LogFile { -//! path: PathBuf, +//! path: PathBuf, //! } //! //! impl LogFile { -//! fn new(path: impl Into) -> Self { -//! Self { path: path.into() } -//! } +//! fn new(path: impl Into) -> Self { +//! Self { path: path.into() } +//! } //! } //! -//! impl StdCommandWrapper for LogFile { -//! fn pre_spawn(&mut self, command: &mut Command, _core: &StdCommandWrap) -> io::Result<()> { -//! let mut logfile = File::create(&self.path)?; -//! let (mut rx, tx) = io::pipe()?; +//! impl CommandWrapper for LogFile { +//! fn pre_spawn(&mut self, command: &mut Command, _core: &CommandWrap) -> io::Result<()> { +//! let mut logfile = File::create(&self.path)?; +//! let (mut rx, tx) = io::pipe()?; //! -//! thread::spawn(move || { -//! io::copy(&mut rx, &mut logfile).unwrap(); -//! }); +//! thread::spawn(move || { +//! io::copy(&mut rx, &mut logfile).unwrap(); +//! }); //! -//! command.stdout(tx.try_clone()?).stderr(tx); -//! Ok(()) -//! } +//! command.stdout(tx.try_clone()?).stderr(tx); +//! Ok(()) +//! } //! } //! ``` //! @@ -192,83 +192,83 @@ //! when calling `.wait()` on the `ChildWrapper`. //! //! ```rust -//! # use process_wrap::std::{StdChildWrapper, StdCommandWrap, StdCommandWrapper}; +//! # use process_wrap::std::{ChildWrapper, CommandWrap, CommandWrapper}; //! # use std::{ -//! # fs::File, -//! # io, mem, -//! # path::PathBuf, -//! # process::{Command, ExitStatus}, -//! # thread::{self, JoinHandle}, +//! # fs::File, +//! # io, mem, +//! # path::PathBuf, +//! # process::{Command, ExitStatus}, +//! # thread::{self, JoinHandle}, //! # }; //! #[derive(Debug)] //! struct LogFile { -//! path: PathBuf, -//! thread: Option>, +//! path: PathBuf, +//! thread: Option>, //! } //! //! impl LogFile { -//! fn new(path: impl Into) -> Self { -//! Self { -//! path: path.into(), -//! thread: None, -//! } -//! } +//! fn new(path: impl Into) -> Self { +//! Self { +//! path: path.into(), +//! thread: None, +//! } +//! } //! } //! -//! impl StdCommandWrapper for LogFile { -//! fn pre_spawn(&mut self, command: &mut Command, _core: &StdCommandWrap) -> io::Result<()> { -//! let mut logfile = File::create(&self.path)?; -//! let (mut rx, tx) = io::pipe()?; -//! -//! self.thread = Some(thread::spawn(move || { -//! io::copy(&mut rx, &mut logfile).unwrap(); -//! })); -//! -//! command.stdout(tx.try_clone()?).stderr(tx); -//! Ok(()) -//! } -//! -//! fn wrap_child( -//! &mut self, -//! child: Box, -//! _core: &StdCommandWrap, -//! ) -> io::Result> { -//! let wrapped_child = LogFileChild { -//! inner: child, -//! thread: mem::take(&mut self.thread), -//! }; -//! Ok(Box::new(wrapped_child)) -//! } +//! impl CommandWrapper for LogFile { +//! fn pre_spawn(&mut self, command: &mut Command, _core: &CommandWrap) -> io::Result<()> { +//! let mut logfile = File::create(&self.path)?; +//! let (mut rx, tx) = io::pipe()?; +//! +//! self.thread = Some(thread::spawn(move || { +//! io::copy(&mut rx, &mut logfile).unwrap(); +//! })); +//! +//! command.stdout(tx.try_clone()?).stderr(tx); +//! Ok(()) +//! } +//! +//! fn wrap_child( +//! &mut self, +//! child: Box, +//! _core: &CommandWrap, +//! ) -> io::Result> { +//! let wrapped_child = LogFileChild { +//! inner: child, +//! thread: mem::take(&mut self.thread), +//! }; +//! Ok(Box::new(wrapped_child)) +//! } //! } //! //! #[derive(Debug)] //! struct LogFileChild { -//! inner: Box, -//! thread: Option>, +//! inner: Box, +//! thread: Option>, //! } //! -//! impl StdChildWrapper for LogFileChild { -//! fn inner(&self) -> &dyn StdChildWrapper { -//! &*self.inner -//! } +//! impl ChildWrapper for LogFileChild { +//! fn inner(&self) -> &dyn ChildWrapper { +//! &*self.inner +//! } //! -//! fn inner_mut(&mut self) -> &mut dyn StdChildWrapper { -//! &mut *self.inner -//! } +//! fn inner_mut(&mut self) -> &mut dyn ChildWrapper { +//! &mut *self.inner +//! } //! -//! fn into_inner(self: Box) -> Box { -//! self.inner -//! } +//! fn into_inner(self: Box) -> Box { +//! self.inner +//! } //! -//! fn wait(&mut self) -> io::Result { -//! let exit_status = self.inner.wait(); +//! fn wait(&mut self) -> io::Result { +//! let exit_status = self.inner.wait(); //! -//! if let Some(thread) = mem::take(&mut self.thread) { -//! thread.join().unwrap(); -//! } +//! if let Some(thread) = mem::take(&mut self.thread) { +//! thread.join().unwrap(); +//! } //! -//! exit_status -//! } +//! exit_status +//! } //! } //! ``` //! @@ -283,152 +283,152 @@ //! setting its `stdin` and `stdout` to `Stdio::null()` in `CommandWrapper::post_spawn()`. //! //! ```rust -//! # use process_wrap::std::{StdCommandWrap, StdCommandWrapper}; +//! # use process_wrap::std::{CommandWrap, CommandWrapper}; //! # use std::{ -//! # io, -//! # path::PathBuf, -//! # process::{Child, Command, Stdio}, -//! # thread::JoinHandle, +//! # io, +//! # path::PathBuf, +//! # process::{Child, Command, Stdio}, +//! # thread::JoinHandle, //! # }; //! # #[derive(Debug)] //! # struct LogFile { -//! # path: PathBuf, -//! # thread: Option>, +//! # path: PathBuf, +//! # thread: Option>, //! # } //! # -//! impl StdCommandWrapper for LogFile { -//! // ... snip ... -//! fn post_spawn( -//! &mut self, -//! command: &mut Command, -//! _child: &mut Child, -//! _core: &StdCommandWrap, -//! ) -> io::Result<()> { -//! command.stdout(Stdio::null()).stderr(Stdio::null()); -//! -//! Ok(()) -//! } -//! // ... snip ... +//! impl CommandWrapper for LogFile { +//! // ... snip ... +//! fn post_spawn( +//! &mut self, +//! command: &mut Command, +//! _child: &mut Child, +//! _core: &CommandWrap, +//! ) -> io::Result<()> { +//! command.stdout(Stdio::null()).stderr(Stdio::null()); +//! +//! Ok(()) +//! } +//! // ... snip ... //! } //! ``` //! //! Finally, we can test that our new command-wrapper works: //! //! ```rust -//! # use process_wrap::std::{StdChildWrapper, StdCommandWrap, StdCommandWrapper}; +//! # use process_wrap::std::{ChildWrapper, CommandWrap, CommandWrapper}; //! # use std::{ -//! # error::Error, -//! # fs::{self, File}, -//! # io, mem, -//! # path::PathBuf, -//! # process::{Child, Command, ExitStatus, Stdio}, -//! # thread::{self, JoinHandle}, +//! # error::Error, +//! # fs::{self, File}, +//! # io, mem, +//! # path::PathBuf, +//! # process::{Child, Command, ExitStatus, Stdio}, +//! # thread::{self, JoinHandle}, //! # }; //! # use tempfile::NamedTempFile; //! # #[derive(Debug)] //! # struct LogFile { -//! # path: PathBuf, -//! # thread: Option>, +//! # path: PathBuf, +//! # thread: Option>, //! # } //! # //! # impl LogFile { -//! # fn new(path: impl Into) -> Self { -//! # Self { -//! # path: path.into(), -//! # thread: None, -//! # } -//! # } +//! # fn new(path: impl Into) -> Self { +//! # Self { +//! # path: path.into(), +//! # thread: None, +//! # } +//! # } //! # } //! # -//! # impl StdCommandWrapper for LogFile { -//! # fn pre_spawn(&mut self, command: &mut Command, _core: &StdCommandWrap) -> io::Result<()> { -//! # let mut logfile = File::create(&self.path)?; -//! # let (mut rx, tx) = io::pipe()?; +//! # impl CommandWrapper for LogFile { +//! # fn pre_spawn(&mut self, command: &mut Command, _core: &CommandWrap) -> io::Result<()> { +//! # let mut logfile = File::create(&self.path)?; +//! # let (mut rx, tx) = io::pipe()?; //! # -//! # self.thread = Some(thread::spawn(move || { -//! # io::copy(&mut rx, &mut logfile).unwrap(); -//! # })); +//! # self.thread = Some(thread::spawn(move || { +//! # io::copy(&mut rx, &mut logfile).unwrap(); +//! # })); //! # -//! # command.stdout(tx.try_clone()?).stderr(tx); -//! # Ok(()) -//! # } +//! # command.stdout(tx.try_clone()?).stderr(tx); +//! # Ok(()) +//! # } //! # -//! # fn post_spawn( -//! # &mut self, -//! # command: &mut Command, -//! # _child: &mut Child, -//! # _core: &StdCommandWrap, -//! # ) -> io::Result<()> { -//! # command.stdout(Stdio::null()).stderr(Stdio::null()); +//! # fn post_spawn( +//! # &mut self, +//! # command: &mut Command, +//! # _child: &mut Child, +//! # _core: &CommandWrap, +//! # ) -> io::Result<()> { +//! # command.stdout(Stdio::null()).stderr(Stdio::null()); //! # -//! # Ok(()) -//! # } +//! # Ok(()) +//! # } //! # -//! # fn wrap_child( -//! # &mut self, -//! # child: Box, -//! # _core: &StdCommandWrap, -//! # ) -> io::Result> { -//! # let wrapped_child = LogFileChild { -//! # inner: child, -//! # thread: mem::take(&mut self.thread), -//! # }; -//! # Ok(Box::new(wrapped_child)) -//! # } +//! # fn wrap_child( +//! # &mut self, +//! # child: Box, +//! # _core: &CommandWrap, +//! # ) -> io::Result> { +//! # let wrapped_child = LogFileChild { +//! # inner: child, +//! # thread: mem::take(&mut self.thread), +//! # }; +//! # Ok(Box::new(wrapped_child)) +//! # } //! # } //! # //! # #[derive(Debug)] //! # struct LogFileChild { -//! # inner: Box, -//! # thread: Option>, +//! # inner: Box, +//! # thread: Option>, //! # } //! # -//! # impl StdChildWrapper for LogFileChild { -//! # fn inner(&self) -> &dyn StdChildWrapper { -//! # &*self.inner -//! # } +//! # impl ChildWrapper for LogFileChild { +//! # fn inner(&self) -> &dyn ChildWrapper { +//! # &*self.inner +//! # } //! # -//! # fn inner_mut(&mut self) -> &mut dyn StdChildWrapper { -//! # &mut *self.inner -//! # } +//! # fn inner_mut(&mut self) -> &mut dyn ChildWrapper { +//! # &mut *self.inner +//! # } //! # -//! # fn into_inner(self: Box) -> Box { -//! # self.inner -//! # } +//! # fn into_inner(self: Box) -> Box { +//! # self.inner +//! # } //! # -//! # fn wait(&mut self) -> io::Result { -//! # let exit_status = self.inner.wait(); +//! # fn wait(&mut self) -> io::Result { +//! # let exit_status = self.inner.wait(); //! # -//! # if let Some(thread) = mem::take(&mut self.thread) { -//! # thread.join().unwrap(); -//! # } +//! # if let Some(thread) = mem::take(&mut self.thread) { +//! # thread.join().unwrap(); +//! # } //! # -//! # exit_status -//! # } +//! # exit_status +//! # } //! # } //! # //! fn main() -> Result<(), Box> { -//! #[cfg(windows)] -//! let mut command = StdCommandWrap::with_new("cmd", |command| { -//! command.args(["/c", "echo Hello && echo World 1>&2"]); -//! }); -//! #[cfg(unix)] -//! let mut command = StdCommandWrap::with_new("sh", |command| { -//! command.args(["-c", "echo Hello && echo World 1>&2"]); -//! }); -//! -//! let logfile = NamedTempFile::new()?; -//! let logfile_path = logfile.path(); -//! -//! command.wrap(LogFile::new(logfile_path)).spawn()?.wait()?; -//! -//! let logfile_lines: Vec = fs::read_to_string(logfile_path)? -//! .lines() -//! .map(|l| l.trim().into()) -//! .collect(); -//! assert_eq!(logfile_lines, vec!["Hello", "World"]); -//! -//! Ok(()) +//! #[cfg(windows)] +//! let mut command = CommandWrap::with_new("cmd", |command| { +//! command.args(["/c", "echo Hello && echo World 1>&2"]); +//! }); +//! #[cfg(unix)] +//! let mut command = CommandWrap::with_new("sh", |command| { +//! command.args(["-c", "echo Hello && echo World 1>&2"]); +//! }); +//! +//! let logfile = NamedTempFile::new()?; +//! let logfile_path = logfile.path(); +//! +//! command.wrap(LogFile::new(logfile_path)).spawn()?.wait()?; +//! +//! let logfile_lines: Vec = fs::read_to_string(logfile_path)? +//! .lines() +//! .map(|l| l.trim().into()) +//! .collect(); +//! assert_eq!(logfile_lines, vec!["Hello", "World"]); +//! +//! Ok(()) //! } //! ``` //! diff --git a/src/std.rs b/src/std.rs index f3e30fd..8f9451a 100644 --- a/src/std.rs +++ b/src/std.rs @@ -9,7 +9,7 @@ //! ``` #[doc(inline)] -pub use core::{StdChildWrapper, StdCommandWrap, StdCommandWrapper}; +pub use core::{ChildWrapper, CommandWrap, CommandWrapper}; #[cfg(all(windows, feature = "creation-flags"))] #[doc(inline)] pub use creation_flags::CreationFlags; diff --git a/src/std/core.rs b/src/std/core.rs index 86e0f59..6164aec 100644 --- a/src/std/core.rs +++ b/src/std/core.rs @@ -10,14 +10,7 @@ use nix::{ unistd::Pid, }; -crate::generic_wrap::Wrap!( - StdCommandWrap, - Command, - StdCommandWrapper, - Child, - StdChildWrapper, - |child| child -); +crate::generic_wrap::Wrap!(Command, Child, ChildWrapper, |child| child); /// Wrapper for `std::process::Child`. /// @@ -41,39 +34,39 @@ crate::generic_wrap::Wrap!( /// #[derive(Debug)] /// pub struct YourChildWrapper(Child); /// -/// impl StdChildWrapper for YourChildWrapper { -/// fn inner(&self) -> &dyn StdChildWrapper { +/// impl ChildWrapper for YourChildWrapper { +/// fn inner(&self) -> &dyn ChildWrapper { /// &self.0 /// } /// -/// fn inner_mut(&mut self) -> &mut dyn StdChildWrapper { +/// fn inner_mut(&mut self) -> &mut dyn ChildWrapper { /// &mut self.0 /// } /// -/// fn into_inner(self: Box) -> Box { +/// fn into_inner(self: Box) -> Box { /// Box::new((*self).0) /// } /// } /// ``` -pub trait StdChildWrapper: Any + std::fmt::Debug + Send { +pub trait ChildWrapper: Any + std::fmt::Debug + Send { /// Obtain a reference to the wrapped child. - fn inner(&self) -> &dyn StdChildWrapper; + fn inner(&self) -> &dyn ChildWrapper; /// Obtain a mutable reference to the wrapped child. - fn inner_mut(&mut self) -> &mut dyn StdChildWrapper; + fn inner_mut(&mut self) -> &mut dyn ChildWrapper; /// Consume the current wrapper and return the wrapped child. /// /// Note that this may disrupt whatever the current wrapper was doing. However, wrappers must /// ensure that the wrapped child is in a consistent state when this is called or they are /// dropped, so that this is always safe. - fn into_inner(self: Box) -> Box; + fn into_inner(self: Box) -> Box; /// Obtain a clone if possible. /// /// Some implementations may make it possible to clone the implementing structure, even though /// std's `Child` isn't `Clone`. In those cases, this method should be overridden. - fn try_clone(&self) -> Option> { + fn try_clone(&self) -> Option> { None } @@ -201,14 +194,14 @@ pub trait StdChildWrapper: Any + std::fmt::Debug + Send { } } -impl StdChildWrapper for Child { - fn inner(&self) -> &dyn StdChildWrapper { +impl ChildWrapper for Child { + fn inner(&self) -> &dyn ChildWrapper { self } - fn inner_mut(&mut self) -> &mut dyn StdChildWrapper { + fn inner_mut(&mut self) -> &mut dyn ChildWrapper { self } - fn into_inner(self: Box) -> Box { + fn into_inner(self: Box) -> Box { self } fn stdin(&mut self) -> &mut Option { @@ -250,7 +243,7 @@ impl StdChildWrapper for Child { } } -impl dyn StdChildWrapper { +impl dyn ChildWrapper { fn downcast_ref(&self) -> Option<&T> { (self as &dyn Any).downcast_ref() } diff --git a/src/std/creation_flags.rs b/src/std/creation_flags.rs index 1b0a85a..00c08c5 100644 --- a/src/std/creation_flags.rs +++ b/src/std/creation_flags.rs @@ -2,7 +2,7 @@ use std::{io::Result, os::windows::process::CommandExt, process::Command}; use windows::Win32::System::Threading::PROCESS_CREATION_FLAGS; -use super::{StdCommandWrap, StdCommandWrapper}; +use super::{CommandWrap, CommandWrapper}; /// Shim wrapper which sets Windows process creation flags. /// @@ -18,8 +18,8 @@ use super::{StdCommandWrap, StdCommandWrapper}; #[derive(Clone, Copy, Debug)] pub struct CreationFlags(pub PROCESS_CREATION_FLAGS); -impl StdCommandWrapper for CreationFlags { - fn pre_spawn(&mut self, command: &mut Command, _core: &StdCommandWrap) -> Result<()> { +impl CommandWrapper for CreationFlags { + fn pre_spawn(&mut self, command: &mut Command, _core: &CommandWrap) -> Result<()> { command.creation_flags((self.0).0); Ok(()) } diff --git a/src/std/job_object.rs b/src/std/job_object.rs index f557e97..586b624 100644 --- a/src/std/job_object.rs +++ b/src/std/job_object.rs @@ -19,7 +19,7 @@ use crate::{ #[cfg(feature = "creation-flags")] use super::CreationFlags; -use super::{StdChildWrapper, StdCommandWrap, StdCommandWrapper}; +use super::{ChildWrapper, CommandWrap, CommandWrapper}; /// Wrapper which creates a job object context for a `Command`. /// @@ -37,9 +37,9 @@ use super::{StdChildWrapper, StdCommandWrap, StdCommandWrapper}; #[derive(Clone, Copy, Debug)] pub struct JobObject; -impl StdCommandWrapper for JobObject { +impl CommandWrapper for JobObject { #[cfg_attr(feature = "tracing", instrument(level = "debug", skip(self)))] - fn pre_spawn(&mut self, command: &mut Command, core: &StdCommandWrap) -> Result<()> { + fn pre_spawn(&mut self, command: &mut Command, core: &CommandWrap) -> Result<()> { let mut flags = CREATE_SUSPENDED; #[cfg(feature = "creation-flags")] if let Some(CreationFlags(user_flags)) = core.get_wrap::() { @@ -53,9 +53,9 @@ impl StdCommandWrapper for JobObject { #[cfg_attr(feature = "tracing", instrument(level = "debug", skip(self)))] fn wrap_child( &mut self, - inner: Box, - core: &StdCommandWrap, - ) -> Result> { + inner: Box, + core: &CommandWrap, + ) -> Result> { #[cfg(feature = "creation-flags")] let create_suspended = core .get_wrap::() @@ -82,14 +82,14 @@ impl StdCommandWrapper for JobObject { /// Wrapper for `Child` which waits on all processes within the job. #[derive(Debug)] pub struct JobObjectChild { - inner: Box, + inner: Box, exit_status: ChildExitStatus, job_port: JobPort, } impl JobObjectChild { #[cfg_attr(feature = "tracing", instrument(level = "debug", skip(job_port)))] - pub(crate) fn new(inner: Box, job_port: JobPort) -> Self { + pub(crate) fn new(inner: Box, job_port: JobPort) -> Self { Self { inner, exit_status: ChildExitStatus::Running, @@ -98,14 +98,14 @@ impl JobObjectChild { } } -impl StdChildWrapper for JobObjectChild { - fn inner(&self) -> &dyn StdChildWrapper { +impl ChildWrapper for JobObjectChild { + fn inner(&self) -> &dyn ChildWrapper { self.inner.inner() } - fn inner_mut(&mut self) -> &mut dyn StdChildWrapper { + fn inner_mut(&mut self) -> &mut dyn ChildWrapper { self.inner.inner_mut() } - fn into_inner(self: Box) -> Box { + fn into_inner(self: Box) -> Box { // manually drop the completion port let its = std::mem::ManuallyDrop::new(self.job_port); unsafe { CloseHandle(its.completion_port.0) }.ok(); diff --git a/src/std/process_group.rs b/src/std/process_group.rs index d34356d..59cf54c 100644 --- a/src/std/process_group.rs +++ b/src/std/process_group.rs @@ -19,7 +19,7 @@ use tracing::instrument; use crate::ChildExitStatus; -use super::{StdChildWrapper, StdCommandWrap, StdCommandWrapper}; +use super::{ChildWrapper, CommandWrap, CommandWrapper}; /// Wrapper which sets the process group of a `Command`. /// @@ -56,14 +56,14 @@ impl ProcessGroup { /// Wrapper for `Child` which ensures that all processes in the group are reaped. #[derive(Debug)] pub struct ProcessGroupChild { - inner: Box, + inner: Box, exit_status: ChildExitStatus, pgid: Pid, } impl ProcessGroupChild { #[cfg_attr(feature = "tracing", instrument(level = "debug"))] - pub(crate) fn new(inner: Box, pgid: Pid) -> Self { + pub(crate) fn new(inner: Box, pgid: Pid) -> Self { Self { inner, exit_status: ChildExitStatus::Running, @@ -79,9 +79,9 @@ impl ProcessGroupChild { } } -impl StdCommandWrapper for ProcessGroup { +impl CommandWrapper for ProcessGroup { #[cfg_attr(feature = "tracing", instrument(level = "debug", skip(self)))] - fn pre_spawn(&mut self, command: &mut Command, _core: &StdCommandWrap) -> Result<()> { + fn pre_spawn(&mut self, command: &mut Command, _core: &CommandWrap) -> Result<()> { command.process_group(self.leader.as_raw()); Ok(()) } @@ -89,9 +89,9 @@ impl StdCommandWrapper for ProcessGroup { #[cfg_attr(feature = "tracing", instrument(level = "debug", skip(self)))] fn wrap_child( &mut self, - inner: Box, - _core: &StdCommandWrap, - ) -> Result> { + inner: Box, + _core: &CommandWrap, + ) -> Result> { let pgid = Pid::from_raw(i32::try_from(inner.id()).expect("Command PID > i32::MAX")); Ok(Box::new(ProcessGroupChild::new(inner, pgid))) @@ -149,14 +149,14 @@ impl ProcessGroupChild { } } -impl StdChildWrapper for ProcessGroupChild { - fn inner(&self) -> &dyn StdChildWrapper { +impl ChildWrapper for ProcessGroupChild { + fn inner(&self) -> &dyn ChildWrapper { self.inner.inner() } - fn inner_mut(&mut self) -> &mut dyn StdChildWrapper { + fn inner_mut(&mut self) -> &mut dyn ChildWrapper { self.inner.inner_mut() } - fn into_inner(self: Box) -> Box { + fn into_inner(self: Box) -> Box { self.inner.into_inner() } diff --git a/src/std/process_session.rs b/src/std/process_session.rs index 42c9a0b..235f7f8 100644 --- a/src/std/process_session.rs +++ b/src/std/process_session.rs @@ -8,7 +8,7 @@ use nix::unistd::{setsid, Pid}; #[cfg(feature = "tracing")] use tracing::instrument; -use super::{StdCommandWrap, StdCommandWrapper}; +use super::{CommandWrap, CommandWrapper}; /// Wrapper which creates a new session and group for the `Command`. /// @@ -25,9 +25,9 @@ use super::{StdCommandWrap, StdCommandWrapper}; #[derive(Clone, Copy, Debug)] pub struct ProcessSession; -impl StdCommandWrapper for ProcessSession { +impl CommandWrapper for ProcessSession { #[cfg_attr(feature = "tracing", instrument(level = "debug", skip(self)))] - fn pre_spawn(&mut self, command: &mut Command, _core: &StdCommandWrap) -> Result<()> { + fn pre_spawn(&mut self, command: &mut Command, _core: &CommandWrap) -> Result<()> { unsafe { command.pre_exec(move || setsid().map_err(Error::from).map(|_| ())); } @@ -38,9 +38,9 @@ impl StdCommandWrapper for ProcessSession { #[cfg_attr(feature = "tracing", instrument(level = "debug", skip(self)))] fn wrap_child( &mut self, - inner: Box, - _core: &StdCommandWrap, - ) -> Result> { + inner: Box, + _core: &CommandWrap, + ) -> Result> { let pgid = Pid::from_raw(i32::try_from(inner.id()).expect("Command PID > i32::MAX")); Ok(Box::new(super::ProcessGroupChild::new(inner, pgid))) diff --git a/src/std/reset_sigmask.rs b/src/std/reset_sigmask.rs index adbdbf6..dc8e03b 100644 --- a/src/std/reset_sigmask.rs +++ b/src/std/reset_sigmask.rs @@ -4,7 +4,7 @@ use nix::sys::signal::{sigprocmask, SigSet, SigmaskHow}; #[cfg(feature = "tracing")] use tracing::trace; -use super::{StdCommandWrap, StdCommandWrapper}; +use super::{CommandWrap, CommandWrapper}; /// Wrapper which resets the process signal mask. /// @@ -13,8 +13,8 @@ use super::{StdCommandWrap, StdCommandWrapper}; #[derive(Clone, Copy, Debug)] pub struct ResetSigmask; -impl StdCommandWrapper for ResetSigmask { - fn pre_spawn(&mut self, command: &mut Command, _core: &StdCommandWrap) -> Result<()> { +impl CommandWrapper for ResetSigmask { + fn pre_spawn(&mut self, command: &mut Command, _core: &CommandWrap) -> Result<()> { unsafe { command.pre_exec(|| { let mut oldset = SigSet::empty(); diff --git a/src/tokio.rs b/src/tokio.rs index 28bee52..4eb8f75 100644 --- a/src/tokio.rs +++ b/src/tokio.rs @@ -9,7 +9,7 @@ //! ``` #[doc(inline)] -pub use core::{TokioChildWrapper, TokioCommandWrap, TokioCommandWrapper}; +pub use core::{ChildWrapper, CommandWrap, CommandWrapper}; #[cfg(all(windows, feature = "creation-flags"))] #[doc(inline)] pub use creation_flags::CreationFlags; diff --git a/src/tokio/core.rs b/src/tokio/core.rs index e3d232b..d06a149 100644 --- a/src/tokio/core.rs +++ b/src/tokio/core.rs @@ -17,14 +17,7 @@ use tokio::{ process::{Child, ChildStderr, ChildStdin, ChildStdout, Command}, }; -crate::generic_wrap::Wrap!( - TokioCommandWrap, - Command, - TokioCommandWrapper, - Child, - TokioChildWrapper, - |child| child -); +crate::generic_wrap::Wrap!(Command, Child, ChildWrapper, |child| child); /// Wrapper for `tokio::process::Child`. /// @@ -47,39 +40,39 @@ crate::generic_wrap::Wrap!( /// #[derive(Debug)] /// pub struct YourChildWrapper(Child); /// -/// impl TokioChildWrapper for YourChildWrapper { -/// fn inner(&self) -> &dyn TokioChildWrapper { +/// impl ChildWrapper for YourChildWrapper { +/// fn inner(&self) -> &dyn ChildWrapper { /// &self.0 /// } /// -/// fn inner_mut(&mut self) -> &mut dyn TokioChildWrapper { +/// fn inner_mut(&mut self) -> &mut dyn ChildWrapper { /// &mut self.0 /// } /// -/// fn into_inner(self: Box) -> Box { +/// fn into_inner(self: Box) -> Box { /// Box::new((*self).0) /// } /// } /// ``` -pub trait TokioChildWrapper: Any + std::fmt::Debug + Send { +pub trait ChildWrapper: Any + std::fmt::Debug + Send { /// Obtain a reference to the wrapped child. - fn inner(&self) -> &dyn TokioChildWrapper; + fn inner(&self) -> &dyn ChildWrapper; /// Obtain a mutable reference to the wrapped child. - fn inner_mut(&mut self) -> &mut dyn TokioChildWrapper; + fn inner_mut(&mut self) -> &mut dyn ChildWrapper; /// Consume the current wrapper and return the wrapped child. /// /// Note that this may disrupt whatever the current wrapper was doing. However, wrappers must /// ensure that the wrapped child is in a consistent state when this is called or they are /// dropped, so that this is always safe. - fn into_inner(self: Box) -> Box; + fn into_inner(self: Box) -> Box; /// Obtain a clone if possible. /// /// Some implementations may make it possible to clone the implementing structure, even though /// Tokio's `Child` isn't `Clone`. In those cases, this method should be overridden. - fn try_clone(&self) -> Option> { + fn try_clone(&self) -> Option> { None } @@ -206,14 +199,14 @@ pub trait TokioChildWrapper: Any + std::fmt::Debug + Send { } } -impl TokioChildWrapper for Child { - fn inner(&self) -> &dyn TokioChildWrapper { +impl ChildWrapper for Child { + fn inner(&self) -> &dyn ChildWrapper { self } - fn inner_mut(&mut self) -> &mut dyn TokioChildWrapper { + fn inner_mut(&mut self) -> &mut dyn ChildWrapper { self } - fn into_inner(self: Box) -> Box { + fn into_inner(self: Box) -> Box { Box::new(*self) } fn stdin(&mut self) -> &mut Option { @@ -251,7 +244,7 @@ impl TokioChildWrapper for Child { } } -impl dyn TokioChildWrapper { +impl dyn ChildWrapper { fn downcast_ref(&self) -> Option<&T> { (self as &dyn Any).downcast_ref() } diff --git a/src/tokio/creation_flags.rs b/src/tokio/creation_flags.rs index af9ebb4..58e1575 100644 --- a/src/tokio/creation_flags.rs +++ b/src/tokio/creation_flags.rs @@ -3,7 +3,7 @@ use std::io::Result; use tokio::process::Command; use windows::Win32::System::Threading::PROCESS_CREATION_FLAGS; -use super::{TokioCommandWrap, TokioCommandWrapper}; +use super::{CommandWrap, CommandWrapper}; /// Shim wrapper which sets Windows process creation flags. /// @@ -19,8 +19,8 @@ use super::{TokioCommandWrap, TokioCommandWrapper}; #[derive(Clone, Copy, Debug)] pub struct CreationFlags(pub PROCESS_CREATION_FLAGS); -impl TokioCommandWrapper for CreationFlags { - fn pre_spawn(&mut self, command: &mut Command, _core: &TokioCommandWrap) -> Result<()> { +impl CommandWrapper for CreationFlags { + fn pre_spawn(&mut self, command: &mut Command, _core: &CommandWrap) -> Result<()> { command.creation_flags((self.0).0); Ok(()) } diff --git a/src/tokio/job_object.rs b/src/tokio/job_object.rs index a5cf64a..ce33feb 100644 --- a/src/tokio/job_object.rs +++ b/src/tokio/job_object.rs @@ -17,7 +17,7 @@ use crate::{ use super::CreationFlags; #[cfg(feature = "kill-on-drop")] use super::KillOnDrop; -use super::{TokioChildWrapper, TokioCommandWrap, TokioCommandWrapper}; +use super::{ChildWrapper, CommandWrap, CommandWrapper}; /// Wrapper which creates a job object context for a `Command`. /// @@ -35,9 +35,9 @@ use super::{TokioChildWrapper, TokioCommandWrap, TokioCommandWrapper}; #[derive(Clone, Copy, Debug)] pub struct JobObject; -impl TokioCommandWrapper for JobObject { +impl CommandWrapper for JobObject { #[cfg_attr(feature = "tracing", instrument(level = "debug", skip(self)))] - fn pre_spawn(&mut self, command: &mut Command, core: &TokioCommandWrap) -> Result<()> { + fn pre_spawn(&mut self, command: &mut Command, core: &CommandWrap) -> Result<()> { let mut flags = CREATE_SUSPENDED; #[cfg(feature = "creation-flags")] if let Some(CreationFlags(user_flags)) = core.get_wrap::() { @@ -51,9 +51,9 @@ impl TokioCommandWrapper for JobObject { #[cfg_attr(feature = "tracing", instrument(level = "debug", skip(self)))] fn wrap_child( &mut self, - inner: Box, - core: &TokioCommandWrap, - ) -> Result> { + inner: Box, + core: &CommandWrap, + ) -> Result> { #[cfg(feature = "kill-on-drop")] let kill_on_drop = core.has_wrap::(); #[cfg(not(feature = "kill-on-drop"))] @@ -94,14 +94,14 @@ impl TokioCommandWrapper for JobObject { /// Wrapper for `Child` which waits on all processes within the job. #[derive(Debug)] pub struct JobObjectChild { - inner: Box, + inner: Box, exit_status: ChildExitStatus, job_port: JobPort, } impl JobObjectChild { #[cfg_attr(feature = "tracing", instrument(level = "debug", skip(job_port)))] - pub(crate) fn new(inner: Box, job_port: JobPort) -> Self { + pub(crate) fn new(inner: Box, job_port: JobPort) -> Self { Self { inner, exit_status: ChildExitStatus::Running, @@ -110,14 +110,14 @@ impl JobObjectChild { } } -impl TokioChildWrapper for JobObjectChild { - fn inner(&self) -> &dyn TokioChildWrapper { +impl ChildWrapper for JobObjectChild { + fn inner(&self) -> &dyn ChildWrapper { self.inner.inner() } - fn inner_mut(&mut self) -> &mut dyn TokioChildWrapper { + fn inner_mut(&mut self) -> &mut dyn ChildWrapper { self.inner.inner_mut() } - fn into_inner(self: Box) -> Box { + fn into_inner(self: Box) -> Box { // manually drop the completion port let its = std::mem::ManuallyDrop::new(self.job_port); unsafe { CloseHandle(its.completion_port.0) }.ok(); diff --git a/src/tokio/kill_on_drop.rs b/src/tokio/kill_on_drop.rs index 84bc677..0eed5cf 100644 --- a/src/tokio/kill_on_drop.rs +++ b/src/tokio/kill_on_drop.rs @@ -2,7 +2,7 @@ use std::io::Result; use tokio::process::Command; -use super::{TokioCommandWrap, TokioCommandWrapper}; +use super::{CommandWrap, CommandWrapper}; /// Shim wrapper which sets kill-on-drop on a `Command`. /// @@ -12,8 +12,8 @@ use super::{TokioCommandWrap, TokioCommandWrapper}; #[derive(Clone, Copy, Debug)] pub struct KillOnDrop; -impl TokioCommandWrapper for KillOnDrop { - fn pre_spawn(&mut self, command: &mut Command, _core: &TokioCommandWrap) -> Result<()> { +impl CommandWrapper for KillOnDrop { + fn pre_spawn(&mut self, command: &mut Command, _core: &CommandWrap) -> Result<()> { command.kill_on_drop(true); Ok(()) } diff --git a/src/tokio/process_group.rs b/src/tokio/process_group.rs index 6b45255..118afcc 100644 --- a/src/tokio/process_group.rs +++ b/src/tokio/process_group.rs @@ -22,7 +22,7 @@ use tracing::instrument; use crate::ChildExitStatus; -use super::{TokioChildWrapper, TokioCommandWrap, TokioCommandWrapper}; +use super::{ChildWrapper, CommandWrap, CommandWrapper}; /// Wrapper which sets the process group of a `Command`. /// @@ -59,14 +59,14 @@ impl ProcessGroup { /// Wrapper for `Child` which ensures that all processes in the group are reaped. #[derive(Debug)] pub struct ProcessGroupChild { - inner: Box, + inner: Box, exit_status: ChildExitStatus, pgid: Pid, } impl ProcessGroupChild { #[cfg_attr(feature = "tracing", instrument(level = "debug"))] - pub(crate) fn new(inner: Box, pgid: Pid) -> Self { + pub(crate) fn new(inner: Box, pgid: Pid) -> Self { Self { inner, exit_status: ChildExitStatus::Running, @@ -82,9 +82,9 @@ impl ProcessGroupChild { } } -impl TokioCommandWrapper for ProcessGroup { +impl CommandWrapper for ProcessGroup { #[cfg_attr(feature = "tracing", instrument(level = "debug", skip(self)))] - fn pre_spawn(&mut self, command: &mut Command, _core: &TokioCommandWrap) -> Result<()> { + fn pre_spawn(&mut self, command: &mut Command, _core: &CommandWrap) -> Result<()> { command.process_group(self.leader.as_raw()); Ok(()) } @@ -92,9 +92,9 @@ impl TokioCommandWrapper for ProcessGroup { #[cfg_attr(feature = "tracing", instrument(level = "debug", skip(self)))] fn wrap_child( &mut self, - inner: Box, - _core: &TokioCommandWrap, - ) -> Result> { + inner: Box, + _core: &CommandWrap, + ) -> Result> { let pgid = Pid::from_raw( i32::try_from( inner @@ -159,14 +159,14 @@ impl ProcessGroupChild { } } -impl TokioChildWrapper for ProcessGroupChild { - fn inner(&self) -> &dyn TokioChildWrapper { +impl ChildWrapper for ProcessGroupChild { + fn inner(&self) -> &dyn ChildWrapper { self.inner.inner() } - fn inner_mut(&mut self) -> &mut dyn TokioChildWrapper { + fn inner_mut(&mut self) -> &mut dyn ChildWrapper { self.inner.inner_mut() } - fn into_inner(self: Box) -> Box { + fn into_inner(self: Box) -> Box { self.inner.into_inner() } diff --git a/src/tokio/process_session.rs b/src/tokio/process_session.rs index 5f4dfac..869e522 100644 --- a/src/tokio/process_session.rs +++ b/src/tokio/process_session.rs @@ -5,7 +5,7 @@ use tokio::process::Command; #[cfg(feature = "tracing")] use tracing::instrument; -use super::{TokioCommandWrap, TokioCommandWrapper}; +use super::{CommandWrap, CommandWrapper}; /// Wrapper which creates a new session and group for the `Command`. /// @@ -22,9 +22,9 @@ use super::{TokioCommandWrap, TokioCommandWrapper}; #[derive(Clone, Copy, Debug)] pub struct ProcessSession; -impl TokioCommandWrapper for ProcessSession { +impl CommandWrapper for ProcessSession { #[cfg_attr(feature = "tracing", instrument(level = "debug", skip(self)))] - fn pre_spawn(&mut self, command: &mut Command, _core: &TokioCommandWrap) -> Result<()> { + fn pre_spawn(&mut self, command: &mut Command, _core: &CommandWrap) -> Result<()> { unsafe { command.pre_exec(move || setsid().map_err(Error::from).map(|_| ())); } @@ -35,9 +35,9 @@ impl TokioCommandWrapper for ProcessSession { #[cfg_attr(feature = "tracing", instrument(level = "debug", skip(self)))] fn wrap_child( &mut self, - inner: Box, - _core: &TokioCommandWrap, - ) -> Result> { + inner: Box, + _core: &CommandWrap, + ) -> Result> { let pgid = Pid::from_raw( i32::try_from( inner diff --git a/src/tokio/reset_sigmask.rs b/src/tokio/reset_sigmask.rs index f9e25a2..0c9696a 100644 --- a/src/tokio/reset_sigmask.rs +++ b/src/tokio/reset_sigmask.rs @@ -5,7 +5,7 @@ use tokio::process::Command; #[cfg(feature = "tracing")] use tracing::trace; -use super::{TokioCommandWrap, TokioCommandWrapper}; +use super::{CommandWrap, CommandWrapper}; /// Wrapper which resets the process signal mask. /// @@ -14,8 +14,8 @@ use super::{TokioCommandWrap, TokioCommandWrapper}; #[derive(Clone, Copy, Debug)] pub struct ResetSigmask; -impl TokioCommandWrapper for ResetSigmask { - fn pre_spawn(&mut self, command: &mut Command, _core: &TokioCommandWrap) -> Result<()> { +impl CommandWrapper for ResetSigmask { + fn pre_spawn(&mut self, command: &mut Command, _core: &CommandWrap) -> Result<()> { unsafe { command.pre_exec(|| { let mut oldset = SigSet::empty(); diff --git a/tests/std_unix/id_same_as_inner.rs b/tests/std_unix/id_same_as_inner.rs index 1f70b1b..74060a2 100644 --- a/tests/std_unix/id_same_as_inner.rs +++ b/tests/std_unix/id_same_as_inner.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let child = StdCommandWrap::with_new("echo", |command| { + let child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .spawn()?; @@ -14,7 +14,7 @@ fn nowrap() -> Result<()> { #[test] fn process_group() -> Result<()> { - let child = StdCommandWrap::with_new("echo", |command| { + let child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessGroup::leader()) @@ -27,7 +27,7 @@ fn process_group() -> Result<()> { #[test] fn process_session() -> Result<()> { - let child = StdCommandWrap::with_new("echo", |command| { + let child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessSession) diff --git a/tests/std_unix/inner_read_stdout.rs b/tests/std_unix/inner_read_stdout.rs index 5857fc0..6288e2b 100644 --- a/tests/std_unix/inner_read_stdout.rs +++ b/tests/std_unix/inner_read_stdout.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let mut child = StdCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.arg("hello").stdout(Stdio::piped()); }) .spawn()?; @@ -18,7 +18,7 @@ fn nowrap() -> Result<()> { #[test] fn process_group() -> Result<()> { - let mut child = StdCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.arg("hello").stdout(Stdio::piped()); }) .wrap(ProcessGroup::leader()) @@ -35,7 +35,7 @@ fn process_group() -> Result<()> { #[test] fn process_session() -> Result<()> { - let mut child = StdCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.arg("hello").stdout(Stdio::piped()); }) .wrap(ProcessSession) diff --git a/tests/std_unix/into_inner_write_stdin.rs b/tests/std_unix/into_inner_write_stdin.rs index d133e12..d5b48f8 100644 --- a/tests/std_unix/into_inner_write_stdin.rs +++ b/tests/std_unix/into_inner_write_stdin.rs @@ -3,7 +3,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { let mut child = unsafe { - StdCommandWrap::with_new("cat", |command| { + CommandWrap::with_new("cat", |command| { command.stdin(Stdio::piped()).stdout(Stdio::piped()); }) .spawn()? @@ -26,7 +26,7 @@ fn nowrap() -> Result<()> { #[test] fn process_group() -> Result<()> { let mut child = unsafe { - StdCommandWrap::with_new("cat", |command| { + CommandWrap::with_new("cat", |command| { command.stdin(Stdio::piped()).stdout(Stdio::piped()); }) .wrap(ProcessGroup::leader()) @@ -50,7 +50,7 @@ fn process_group() -> Result<()> { #[test] fn process_session() -> Result<()> { let mut child = unsafe { - StdCommandWrap::with_new("cat", |command| { + CommandWrap::with_new("cat", |command| { command.stdin(Stdio::piped()).stdout(Stdio::piped()); }) .wrap(ProcessSession) diff --git a/tests/std_unix/kill_and_try_wait.rs b/tests/std_unix/kill_and_try_wait.rs index 4a95ee7..781cac0 100644 --- a/tests/std_unix/kill_and_try_wait.rs +++ b/tests/std_unix/kill_and_try_wait.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let mut child = StdCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .spawn()?; @@ -20,7 +20,7 @@ fn nowrap() -> Result<()> { #[test] fn process_group() -> Result<()> { - let mut child = StdCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessGroup::leader()) @@ -43,7 +43,7 @@ fn process_group() -> Result<()> { #[test] fn process_session() -> Result<()> { - let mut child = StdCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessSession) diff --git a/tests/std_unix/multiproc_linux.rs b/tests/std_unix/multiproc_linux.rs index ef82a48..c2d83af 100644 --- a/tests/std_unix/multiproc_linux.rs +++ b/tests/std_unix/multiproc_linux.rs @@ -4,7 +4,7 @@ use super::prelude::*; #[test] fn process_group_kill_leader() -> Result<()> { - let mut leader = StdCommandWrap::with_new("tests/multiproc_helper.rs", |command| { + let mut leader = CommandWrap::with_new("tests/multiproc_helper.rs", |command| { command .arg("1") .arg("10") @@ -46,7 +46,7 @@ fn process_group_kill_leader() -> Result<()> { #[test] fn process_group_kill_group() -> Result<()> { - let mut leader = StdCommandWrap::with_new("tests/multiproc_helper.rs", |command| { + let mut leader = CommandWrap::with_new("tests/multiproc_helper.rs", |command| { command .arg("1") .arg("10") @@ -89,7 +89,7 @@ fn process_group_kill_group() -> Result<()> { #[test] fn process_session_kill_leader() -> Result<()> { - let mut leader = StdCommandWrap::with_new("tests/multiproc_helper.rs", |command| { + let mut leader = CommandWrap::with_new("tests/multiproc_helper.rs", |command| { command .arg("1") .arg("10") @@ -131,7 +131,7 @@ fn process_session_kill_leader() -> Result<()> { #[test] fn process_session_kill_group() -> Result<()> { - let mut leader = StdCommandWrap::with_new("tests/multiproc_helper.rs", |command| { + let mut leader = CommandWrap::with_new("tests/multiproc_helper.rs", |command| { command .arg("1") .arg("10") diff --git a/tests/std_unix/signals.rs b/tests/std_unix/signals.rs index 71196de..b5f511f 100644 --- a/tests/std_unix/signals.rs +++ b/tests/std_unix/signals.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let mut child = StdCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .spawn()?; @@ -20,7 +20,7 @@ fn nowrap() -> Result<()> { #[test] fn process_group() -> Result<()> { - let mut child = StdCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessGroup::leader()) @@ -39,7 +39,7 @@ fn process_group() -> Result<()> { #[test] fn process_session() -> Result<()> { - let mut child = StdCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessSession) diff --git a/tests/std_unix/try_wait_after_die.rs b/tests/std_unix/try_wait_after_die.rs index fc203b1..afbf50f 100644 --- a/tests/std_unix/try_wait_after_die.rs +++ b/tests/std_unix/try_wait_after_die.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let mut child = StdCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .spawn()?; @@ -16,7 +16,7 @@ fn nowrap() -> Result<()> { #[test] fn process_group() -> Result<()> { - let mut child = StdCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessGroup::leader()) @@ -31,7 +31,7 @@ fn process_group() -> Result<()> { #[test] fn process_session() -> Result<()> { - let mut child = StdCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessSession) diff --git a/tests/std_unix/try_wait_twice_after_sigterm.rs b/tests/std_unix/try_wait_twice_after_sigterm.rs index 00f0a8e..c440216 100644 --- a/tests/std_unix/try_wait_twice_after_sigterm.rs +++ b/tests/std_unix/try_wait_twice_after_sigterm.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let mut child = StdCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .spawn()?; @@ -20,7 +20,7 @@ fn nowrap() -> Result<()> { #[test] fn process_group() -> Result<()> { - let mut child = StdCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessGroup::leader()) @@ -39,7 +39,7 @@ fn process_group() -> Result<()> { #[test] fn process_session() -> Result<()> { - let mut child = StdCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessSession) diff --git a/tests/std_unix/wait_after_die.rs b/tests/std_unix/wait_after_die.rs index 7cc71ed..078b71c 100644 --- a/tests/std_unix/wait_after_die.rs +++ b/tests/std_unix/wait_after_die.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let mut child = StdCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .spawn()?; @@ -16,7 +16,7 @@ fn nowrap() -> Result<()> { #[test] fn process_group() -> Result<()> { - let mut child = StdCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessGroup::leader()) @@ -31,7 +31,7 @@ fn process_group() -> Result<()> { #[test] fn process_session() -> Result<()> { - let mut child = StdCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessSession) diff --git a/tests/std_unix/wait_twice.rs b/tests/std_unix/wait_twice.rs index c2cfffd..a089b8f 100644 --- a/tests/std_unix/wait_twice.rs +++ b/tests/std_unix/wait_twice.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let mut child = StdCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .spawn()?; @@ -18,7 +18,7 @@ fn nowrap() -> Result<()> { #[test] fn process_group() -> Result<()> { - let mut child = StdCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessGroup::leader()) @@ -35,7 +35,7 @@ fn process_group() -> Result<()> { #[test] fn process_session() -> Result<()> { - let mut child = StdCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessSession) diff --git a/tests/std_unix/wait_twice_after_sigterm.rs b/tests/std_unix/wait_twice_after_sigterm.rs index 7cb5165..aa57728 100644 --- a/tests/std_unix/wait_twice_after_sigterm.rs +++ b/tests/std_unix/wait_twice_after_sigterm.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let mut child = StdCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .spawn()?; @@ -21,7 +21,7 @@ fn nowrap() -> Result<()> { #[test] fn process_group() -> Result<()> { - let mut child = StdCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessGroup::leader()) @@ -41,7 +41,7 @@ fn process_group() -> Result<()> { #[test] fn process_session() -> Result<()> { - let mut child = StdCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessSession) diff --git a/tests/std_unix/wait_with_output.rs b/tests/std_unix/wait_with_output.rs index ab5d2c6..1285b7a 100644 --- a/tests/std_unix/wait_with_output.rs +++ b/tests/std_unix/wait_with_output.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let child = StdCommandWrap::with_new("echo", |command| { + let child = CommandWrap::with_new("echo", |command| { command.arg("hello").stdout(Stdio::piped()); }) .spawn()?; @@ -16,7 +16,7 @@ fn nowrap() -> Result<()> { #[test] fn process_group() -> Result<()> { - let child = StdCommandWrap::with_new("echo", |command| { + let child = CommandWrap::with_new("echo", |command| { command.arg("hello").stdout(Stdio::piped()); }) .wrap(ProcessGroup::leader()) @@ -31,7 +31,7 @@ fn process_group() -> Result<()> { #[test] fn process_session() -> Result<()> { - let child = StdCommandWrap::with_new("echo", |command| { + let child = CommandWrap::with_new("echo", |command| { command.arg("hello").stdout(Stdio::piped()); }) .wrap(ProcessSession) diff --git a/tests/std_windows/id_same_as_inner.rs b/tests/std_windows/id_same_as_inner.rs index 16c8604..c59d369 100644 --- a/tests/std_windows/id_same_as_inner.rs +++ b/tests/std_windows/id_same_as_inner.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let child = StdCommandWrap::with_new("powershell.exe", |command| { + let child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::null()); }) .spawn()?; @@ -14,7 +14,7 @@ fn nowrap() -> Result<()> { #[test] fn job_object() -> Result<()> { - let child = StdCommandWrap::with_new("powershell.exe", |command| { + let child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::null()); }) .wrap(JobObject) diff --git a/tests/std_windows/inner_read_stdout.rs b/tests/std_windows/inner_read_stdout.rs index 34a1ad4..668ad31 100644 --- a/tests/std_windows/inner_read_stdout.rs +++ b/tests/std_windows/inner_read_stdout.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let mut child = StdCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::piped()); }) .spawn()?; @@ -18,7 +18,7 @@ fn nowrap() -> Result<()> { #[test] fn job_object() -> Result<()> { - let mut child = StdCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::piped()); }) .wrap(JobObject) diff --git a/tests/std_windows/into_inner_write_stdin.rs b/tests/std_windows/into_inner_write_stdin.rs index d19f74d..3cb934f 100644 --- a/tests/std_windows/into_inner_write_stdin.rs +++ b/tests/std_windows/into_inner_write_stdin.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let mut child = StdCommandWrap::with_new("findstr", |command| { + let mut child = CommandWrap::with_new("findstr", |command| { command .arg("^") .stdin(Stdio::piped()) @@ -26,7 +26,7 @@ fn nowrap() -> Result<()> { #[test] fn job_object() -> Result<()> { - let mut child = StdCommandWrap::with_new("findstr", |command| { + let mut child = CommandWrap::with_new("findstr", |command| { command .arg("^") .stdin(Stdio::piped()) diff --git a/tests/std_windows/kill_and_try_wait.rs b/tests/std_windows/kill_and_try_wait.rs index a8b8c67..2f0b03d 100644 --- a/tests/std_windows/kill_and_try_wait.rs +++ b/tests/std_windows/kill_and_try_wait.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let mut child = StdCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("pause").stdout(Stdio::null()); }) .spawn()?; @@ -20,7 +20,7 @@ fn nowrap() -> Result<()> { #[test] fn job_object() -> Result<()> { - let mut child = StdCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("pause").stdout(Stdio::null()); }) .wrap(JobObject) diff --git a/tests/std_windows/try_wait_after_die.rs b/tests/std_windows/try_wait_after_die.rs index 2d8a927..de2e05e 100644 --- a/tests/std_windows/try_wait_after_die.rs +++ b/tests/std_windows/try_wait_after_die.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let mut child = StdCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::null()); }) .spawn()?; @@ -16,7 +16,7 @@ fn nowrap() -> Result<()> { #[test] fn job_object() -> Result<()> { - let mut child = StdCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::null()); }) .wrap(JobObject) diff --git a/tests/std_windows/wait_after_die.rs b/tests/std_windows/wait_after_die.rs index 70264d8..a9cbc0f 100644 --- a/tests/std_windows/wait_after_die.rs +++ b/tests/std_windows/wait_after_die.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let mut child = StdCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::null()); }) .spawn()?; @@ -16,7 +16,7 @@ fn nowrap() -> Result<()> { #[test] fn job_object() -> Result<()> { - let mut child = StdCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::null()); }) .wrap(JobObject) diff --git a/tests/std_windows/wait_twice.rs b/tests/std_windows/wait_twice.rs index 8496306..b103523 100644 --- a/tests/std_windows/wait_twice.rs +++ b/tests/std_windows/wait_twice.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let mut child = StdCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::null()); }) .spawn()?; @@ -18,7 +18,7 @@ fn nowrap() -> Result<()> { #[test] fn job_object() -> Result<()> { - let mut child = StdCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::null()); }) .wrap(JobObject) diff --git a/tests/std_windows/wait_with_output.rs b/tests/std_windows/wait_with_output.rs index 91a7092..dd3a04c 100644 --- a/tests/std_windows/wait_with_output.rs +++ b/tests/std_windows/wait_with_output.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[test] fn nowrap() -> Result<()> { - let child = StdCommandWrap::with_new("powershell.exe", |command| { + let child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::piped()); }) .spawn()?; @@ -16,7 +16,7 @@ fn nowrap() -> Result<()> { #[test] fn job_object() -> Result<()> { - let child = StdCommandWrap::with_new("powershell.exe", |command| { + let child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::piped()); }) .wrap(JobObject) diff --git a/tests/tokio_unix/id_same_as_inner.rs b/tests/tokio_unix/id_same_as_inner.rs index a57c147..2459495 100644 --- a/tests/tokio_unix/id_same_as_inner.rs +++ b/tests/tokio_unix/id_same_as_inner.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let child = TokioCommandWrap::with_new("echo", |command| { + let child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .spawn()?; @@ -14,7 +14,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn process_group() -> Result<()> { - let child = TokioCommandWrap::with_new("echo", |command| { + let child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessGroup::leader()) @@ -27,7 +27,7 @@ async fn process_group() -> Result<()> { #[tokio::test] async fn process_session() -> Result<()> { - let child = TokioCommandWrap::with_new("echo", |command| { + let child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessSession) diff --git a/tests/tokio_unix/inner_read_stdout.rs b/tests/tokio_unix/inner_read_stdout.rs index 8b339c9..22ff018 100644 --- a/tests/tokio_unix/inner_read_stdout.rs +++ b/tests/tokio_unix/inner_read_stdout.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let mut child = TokioCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.arg("hello").stdout(Stdio::piped()); }) .spawn()?; @@ -18,7 +18,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn process_group() -> Result<()> { - let mut child = TokioCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.arg("hello").stdout(Stdio::piped()); }) .wrap(ProcessGroup::leader()) @@ -35,7 +35,7 @@ async fn process_group() -> Result<()> { #[tokio::test] async fn process_session() -> Result<()> { - let mut child = TokioCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.arg("hello").stdout(Stdio::piped()); }) .wrap(ProcessSession) diff --git a/tests/tokio_unix/into_inner_write_stdin.rs b/tests/tokio_unix/into_inner_write_stdin.rs index 64de677..ecd1a0f 100644 --- a/tests/tokio_unix/into_inner_write_stdin.rs +++ b/tests/tokio_unix/into_inner_write_stdin.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let mut child = TokioCommandWrap::with_new("cat", |command| { + let mut child = CommandWrap::with_new("cat", |command| { command.stdin(Stdio::piped()).stdout(Stdio::piped()); }) .spawn()? @@ -23,7 +23,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn process_group() -> Result<()> { - let mut child = TokioCommandWrap::with_new("cat", |command| { + let mut child = CommandWrap::with_new("cat", |command| { command.stdin(Stdio::piped()).stdout(Stdio::piped()); }) .wrap(ProcessGroup::leader()) @@ -45,7 +45,7 @@ async fn process_group() -> Result<()> { #[tokio::test] async fn process_session() -> Result<()> { - let mut child = TokioCommandWrap::with_new("cat", |command| { + let mut child = CommandWrap::with_new("cat", |command| { command.stdin(Stdio::piped()).stdout(Stdio::piped()); }) .wrap(ProcessSession) diff --git a/tests/tokio_unix/kill_and_try_wait.rs b/tests/tokio_unix/kill_and_try_wait.rs index 2c25466..001aca9 100644 --- a/tests/tokio_unix/kill_and_try_wait.rs +++ b/tests/tokio_unix/kill_and_try_wait.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let mut child = TokioCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .spawn()?; @@ -20,7 +20,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn process_group() -> Result<()> { - let mut child = TokioCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessGroup::leader()) @@ -43,7 +43,7 @@ async fn process_group() -> Result<()> { #[tokio::test] async fn process_session() -> Result<()> { - let mut child = TokioCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessSession) diff --git a/tests/tokio_unix/multiproc_linux.rs b/tests/tokio_unix/multiproc_linux.rs index fa41499..f13c448 100644 --- a/tests/tokio_unix/multiproc_linux.rs +++ b/tests/tokio_unix/multiproc_linux.rs @@ -4,7 +4,7 @@ use super::prelude::*; #[tokio::test] async fn process_group_kill_leader() -> Result<()> { - let mut leader = TokioCommandWrap::with_new("tests/multiproc_helper.rs", |command| { + let mut leader = CommandWrap::with_new("tests/multiproc_helper.rs", |command| { command .arg("1") .arg("10") @@ -47,7 +47,7 @@ async fn process_group_kill_leader() -> Result<()> { #[tokio::test] async fn process_group_kill_group() -> Result<()> { - let mut leader = TokioCommandWrap::with_new("tests/multiproc_helper.rs", |command| { + let mut leader = CommandWrap::with_new("tests/multiproc_helper.rs", |command| { command .arg("1") .arg("10") @@ -91,7 +91,7 @@ async fn process_group_kill_group() -> Result<()> { #[tokio::test] async fn process_session_kill_leader() -> Result<()> { - let mut leader = TokioCommandWrap::with_new("tests/multiproc_helper.rs", |command| { + let mut leader = CommandWrap::with_new("tests/multiproc_helper.rs", |command| { command .arg("1") .arg("10") @@ -134,7 +134,7 @@ async fn process_session_kill_leader() -> Result<()> { #[tokio::test] async fn process_session_kill_group() -> Result<()> { - let mut leader = TokioCommandWrap::with_new("tests/multiproc_helper.rs", |command| { + let mut leader = CommandWrap::with_new("tests/multiproc_helper.rs", |command| { command .arg("1") .arg("10") diff --git a/tests/tokio_unix/signals.rs b/tests/tokio_unix/signals.rs index 4de5e71..124635c 100644 --- a/tests/tokio_unix/signals.rs +++ b/tests/tokio_unix/signals.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let mut child = TokioCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .spawn()?; @@ -20,7 +20,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn process_group() -> Result<()> { - let mut child = TokioCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessGroup::leader()) @@ -39,7 +39,7 @@ async fn process_group() -> Result<()> { #[tokio::test] async fn process_session() -> Result<()> { - let mut child = TokioCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessSession) diff --git a/tests/tokio_unix/try_wait_after_die.rs b/tests/tokio_unix/try_wait_after_die.rs index 97efda9..f23bc83 100644 --- a/tests/tokio_unix/try_wait_after_die.rs +++ b/tests/tokio_unix/try_wait_after_die.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let mut child = TokioCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .spawn()?; @@ -16,7 +16,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn process_group() -> Result<()> { - let mut child = TokioCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessGroup::leader()) @@ -31,7 +31,7 @@ async fn process_group() -> Result<()> { #[tokio::test] async fn process_session() -> Result<()> { - let mut child = TokioCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessSession) diff --git a/tests/tokio_unix/try_wait_twice_after_sigterm.rs b/tests/tokio_unix/try_wait_twice_after_sigterm.rs index 39a0415..455b0b4 100644 --- a/tests/tokio_unix/try_wait_twice_after_sigterm.rs +++ b/tests/tokio_unix/try_wait_twice_after_sigterm.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let mut child = TokioCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .spawn()?; @@ -20,7 +20,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn process_group() -> Result<()> { - let mut child = TokioCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessGroup::leader()) @@ -39,7 +39,7 @@ async fn process_group() -> Result<()> { #[tokio::test] async fn process_session() -> Result<()> { - let mut child = TokioCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessSession) diff --git a/tests/tokio_unix/wait_after_die.rs b/tests/tokio_unix/wait_after_die.rs index f1c85f7..4c017a2 100644 --- a/tests/tokio_unix/wait_after_die.rs +++ b/tests/tokio_unix/wait_after_die.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let mut child = TokioCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .spawn()?; @@ -16,7 +16,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn process_group() -> Result<()> { - let mut child = TokioCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessGroup::leader()) @@ -31,7 +31,7 @@ async fn process_group() -> Result<()> { #[tokio::test] async fn process_session() -> Result<()> { - let mut child = TokioCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessSession) diff --git a/tests/tokio_unix/wait_twice.rs b/tests/tokio_unix/wait_twice.rs index 3560cb4..47dfdd7 100644 --- a/tests/tokio_unix/wait_twice.rs +++ b/tests/tokio_unix/wait_twice.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let mut child = TokioCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .spawn()?; @@ -18,7 +18,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn process_group() -> Result<()> { - let mut child = TokioCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessGroup::leader()) @@ -35,7 +35,7 @@ async fn process_group() -> Result<()> { #[tokio::test] async fn process_session() -> Result<()> { - let mut child = TokioCommandWrap::with_new("echo", |command| { + let mut child = CommandWrap::with_new("echo", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessSession) diff --git a/tests/tokio_unix/wait_twice_after_sigterm.rs b/tests/tokio_unix/wait_twice_after_sigterm.rs index e72b4a9..a6b5a53 100644 --- a/tests/tokio_unix/wait_twice_after_sigterm.rs +++ b/tests/tokio_unix/wait_twice_after_sigterm.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let mut child = TokioCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .spawn()?; @@ -21,7 +21,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn process_group() -> Result<()> { - let mut child = TokioCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessGroup::leader()) @@ -41,7 +41,7 @@ async fn process_group() -> Result<()> { #[tokio::test] async fn process_session() -> Result<()> { - let mut child = TokioCommandWrap::with_new("yes", |command| { + let mut child = CommandWrap::with_new("yes", |command| { command.stdout(Stdio::null()); }) .wrap(ProcessSession) diff --git a/tests/tokio_unix/wait_with_output.rs b/tests/tokio_unix/wait_with_output.rs index b414fff..e15771c 100644 --- a/tests/tokio_unix/wait_with_output.rs +++ b/tests/tokio_unix/wait_with_output.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let child = TokioCommandWrap::with_new("echo", |command| { + let child = CommandWrap::with_new("echo", |command| { command.arg("hello").stdout(Stdio::piped()); }) .spawn()?; @@ -16,7 +16,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn process_group() -> Result<()> { - let child = TokioCommandWrap::with_new("echo", |command| { + let child = CommandWrap::with_new("echo", |command| { command.arg("hello").stdout(Stdio::piped()); }) .wrap(ProcessGroup::leader()) @@ -31,7 +31,7 @@ async fn process_group() -> Result<()> { #[tokio::test] async fn process_session() -> Result<()> { - let child = TokioCommandWrap::with_new("echo", |command| { + let child = CommandWrap::with_new("echo", |command| { command.arg("hello").stdout(Stdio::piped()); }) .wrap(ProcessSession) diff --git a/tests/tokio_windows/id_same_as_inner.rs b/tests/tokio_windows/id_same_as_inner.rs index 8b6dbfd..6d2504d 100644 --- a/tests/tokio_windows/id_same_as_inner.rs +++ b/tests/tokio_windows/id_same_as_inner.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let child = TokioCommandWrap::with_new("powershell.exe", |command| { + let child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::null()); }) .spawn()?; @@ -14,7 +14,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn job_object() -> Result<()> { - let child = TokioCommandWrap::with_new("powershell.exe", |command| { + let child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::null()); }) .wrap(JobObject) diff --git a/tests/tokio_windows/inner_read_stdout.rs b/tests/tokio_windows/inner_read_stdout.rs index 7a483b6..3d9a487 100644 --- a/tests/tokio_windows/inner_read_stdout.rs +++ b/tests/tokio_windows/inner_read_stdout.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let mut child = TokioCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::piped()); }) .spawn()?; @@ -18,7 +18,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn job_object() -> Result<()> { - let mut child = TokioCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::piped()); }) .wrap(JobObject) diff --git a/tests/tokio_windows/into_inner_write_stdin.rs b/tests/tokio_windows/into_inner_write_stdin.rs index ac4017b..b278973 100644 --- a/tests/tokio_windows/into_inner_write_stdin.rs +++ b/tests/tokio_windows/into_inner_write_stdin.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let mut child = TokioCommandWrap::with_new("findstr", |command| { + let mut child = CommandWrap::with_new("findstr", |command| { command .arg("^") .stdin(Stdio::piped()) @@ -26,7 +26,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn job_object() -> Result<()> { - let mut child = TokioCommandWrap::with_new("findstr", |command| { + let mut child = CommandWrap::with_new("findstr", |command| { command .arg("^") .stdin(Stdio::piped()) diff --git a/tests/tokio_windows/kill_and_try_wait.rs b/tests/tokio_windows/kill_and_try_wait.rs index 01fb426..e0e42cc 100644 --- a/tests/tokio_windows/kill_and_try_wait.rs +++ b/tests/tokio_windows/kill_and_try_wait.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let mut child = TokioCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("pause").stdout(Stdio::null()); }) .spawn()?; @@ -20,7 +20,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn job_object() -> Result<()> { - let mut child = TokioCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("pause").stdout(Stdio::null()); }) .wrap(JobObject) diff --git a/tests/tokio_windows/try_wait_after_die.rs b/tests/tokio_windows/try_wait_after_die.rs index d24fe18..1ed70c6 100644 --- a/tests/tokio_windows/try_wait_after_die.rs +++ b/tests/tokio_windows/try_wait_after_die.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let mut child = TokioCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::null()); }) .spawn()?; @@ -16,7 +16,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn job_object() -> Result<()> { - let mut child = TokioCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::null()); }) .wrap(JobObject) diff --git a/tests/tokio_windows/wait_after_die.rs b/tests/tokio_windows/wait_after_die.rs index 0b1f840..28e12b1 100644 --- a/tests/tokio_windows/wait_after_die.rs +++ b/tests/tokio_windows/wait_after_die.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let mut child = TokioCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::null()); }) .spawn()?; @@ -16,7 +16,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn job_object() -> Result<()> { - let mut child = TokioCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::null()); }) .wrap(JobObject) diff --git a/tests/tokio_windows/wait_twice.rs b/tests/tokio_windows/wait_twice.rs index c79e9e6..d20241a 100644 --- a/tests/tokio_windows/wait_twice.rs +++ b/tests/tokio_windows/wait_twice.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let mut child = TokioCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::null()); }) .spawn()?; @@ -18,7 +18,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn job_object() -> Result<()> { - let mut child = TokioCommandWrap::with_new("powershell.exe", |command| { + let mut child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::null()); }) .wrap(JobObject) diff --git a/tests/tokio_windows/wait_with_output.rs b/tests/tokio_windows/wait_with_output.rs index d7963a6..cd8b345 100644 --- a/tests/tokio_windows/wait_with_output.rs +++ b/tests/tokio_windows/wait_with_output.rs @@ -2,7 +2,7 @@ use super::prelude::*; #[tokio::test] async fn nowrap() -> Result<()> { - let child = TokioCommandWrap::with_new("powershell.exe", |command| { + let child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::piped()); }) .spawn()?; @@ -16,7 +16,7 @@ async fn nowrap() -> Result<()> { #[tokio::test] async fn job_object() -> Result<()> { - let child = TokioCommandWrap::with_new("powershell.exe", |command| { + let child = CommandWrap::with_new("powershell.exe", |command| { command.arg("/C").arg("echo hello").stdout(Stdio::piped()); }) .wrap(JobObject)