aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-29 14:39:53 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-29 14:39:53 -0500
commite0337dbbb0a919d2bff3c22b90d0f0f17bad775d (patch)
tree6b27af50f179441d784e02f85fc9392cc5dbd335 /src
parentd6e938a3454f70d2b4177d9fb23092f47ad6bb18 (diff)
downloadpty-process-e0337dbbb0a919d2bff3c22b90d0f0f17bad775d.tar.gz
pty-process-e0337dbbb0a919d2bff3c22b90d0f0f17bad775d.zip
simplify
Diffstat (limited to 'src')
-rw-r--r--src/blocking/command.rs45
-rw-r--r--src/blocking/mod.rs2
-rw-r--r--src/command.rs46
-rw-r--r--src/lib.rs2
4 files changed, 12 insertions, 83 deletions
diff --git a/src/blocking/command.rs b/src/blocking/command.rs
index cc3419a..54a5e37 100644
--- a/src/blocking/command.rs
+++ b/src/blocking/command.rs
@@ -97,10 +97,10 @@ impl Command {
pub fn spawn(
&mut self,
- pty: crate::blocking::Pty,
- ) -> crate::Result<Child> {
+ pty: &crate::blocking::Pty,
+ ) -> crate::Result<std::process::Child> {
let (stdin, stdout, stderr, pre_exec) =
- crate::sys::setup_subprocess(&pty, pty.pts()?)?;
+ crate::sys::setup_subprocess(pty, pty.pts()?)?;
self.inner.stdin(self.stdin.take().unwrap_or(stdin));
self.inner.stdout(self.stdout.take().unwrap_or(stdout));
@@ -111,43 +111,6 @@ impl Command {
// async-signal-safe).
unsafe { self.inner.pre_exec(pre_exec) };
- let child = self.inner.spawn()?;
-
- Ok(Child::new(child, pty))
- }
-}
-
-pub struct Child {
- inner: std::process::Child,
- pty: crate::blocking::Pty,
-}
-
-impl Child {
- fn new(inner: std::process::Child, pty: crate::blocking::Pty) -> Self {
- Self { inner, pty }
- }
-
- #[must_use]
- pub fn pty(&self) -> &crate::blocking::Pty {
- &self.pty
- }
-
- #[must_use]
- pub fn pty_mut(&mut self) -> &mut crate::blocking::Pty {
- &mut self.pty
- }
-}
-
-impl std::ops::Deref for Child {
- type Target = std::process::Child;
-
- fn deref(&self) -> &Self::Target {
- &self.inner
- }
-}
-
-impl std::ops::DerefMut for Child {
- fn deref_mut(&mut self) -> &mut Self::Target {
- &mut self.inner
+ Ok(self.inner.spawn()?)
}
}
diff --git a/src/blocking/mod.rs b/src/blocking/mod.rs
index a45b132..cdf66da 100644
--- a/src/blocking/mod.rs
+++ b/src/blocking/mod.rs
@@ -1,4 +1,4 @@
mod command;
-pub use command::{Child, Command};
+pub use command::Command;
mod pty;
pub use pty::Pty;
diff --git a/src/command.rs b/src/command.rs
index ef156aa..18e1f17 100644
--- a/src/command.rs
+++ b/src/command.rs
@@ -95,9 +95,12 @@ impl Command {
self
}
- pub fn spawn(&mut self, pty: crate::Pty) -> crate::Result<Child> {
+ pub fn spawn(
+ &mut self,
+ pty: &crate::Pty,
+ ) -> crate::Result<async_process::Child> {
let (stdin, stdout, stderr, pre_exec) =
- crate::sys::setup_subprocess(&pty, pty.pts()?)?;
+ crate::sys::setup_subprocess(pty, pty.pts()?)?;
self.inner.stdin(self.stdin.take().unwrap_or(stdin));
self.inner.stdout(self.stdout.take().unwrap_or(stdout));
@@ -108,43 +111,6 @@ impl Command {
// async-signal-safe).
unsafe { self.inner.pre_exec(pre_exec) };
- let child = self.inner.spawn()?;
-
- Ok(Child::new(child, pty))
- }
-}
-
-pub struct Child {
- inner: async_process::Child,
- pty: crate::Pty,
-}
-
-impl Child {
- fn new(inner: async_process::Child, pty: crate::Pty) -> Self {
- Self { inner, pty }
- }
-
- #[must_use]
- pub fn pty(&self) -> &crate::Pty {
- &self.pty
- }
-
- #[must_use]
- pub fn pty_mut(&mut self) -> &mut crate::Pty {
- &mut self.pty
- }
-}
-
-impl std::ops::Deref for Child {
- type Target = async_process::Child;
-
- fn deref(&self) -> &Self::Target {
- &self.inner
- }
-}
-
-impl std::ops::DerefMut for Child {
- fn deref_mut(&mut self) -> &mut Self::Target {
- &mut self.inner
+ Ok(self.inner.spawn()?)
}
}
diff --git a/src/lib.rs b/src/lib.rs
index 3f7577f..efb12de 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -23,7 +23,7 @@ pub mod blocking;
#[cfg(feature = "async")]
mod command;
#[cfg(feature = "async")]
-pub use command::{Child, Command};
+pub use command::Command;
#[cfg(feature = "async")]
mod pty;
#[cfg(feature = "async")]