From: Ian Jackson Date: Mon, 31 May 2021 13:08:33 +0000 (+0100) Subject: childio: Some type aliases X-Git-Tag: otter-0.7.0~201 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=932a1afa56a986901f64c0afbf1062e00f16a61b;p=otter.git childio: Some type aliases Signed-off-by: Ian Jackson --- diff --git a/src/childio.rs b/src/childio.rs index 35b43bb4..02bd7dcd 100644 --- a/src/childio.rs +++ b/src/childio.rs @@ -4,7 +4,7 @@ use crate::prelude::*; -use std::process::{self, ChildStdin, ChildStdout}; +use std::process; #[derive(Debug)] pub struct ChildIo { @@ -12,6 +12,10 @@ pub struct ChildIo { child: Arc>, } +pub type Stdin = ChildIo; +pub type Stdout = ChildIo; +pub type Pair = (Stdin /*w*/, Stdout /*r*/); + #[derive(Debug)] struct ChildWrapper { reported: bool, @@ -43,8 +47,7 @@ impl ChildIo { } } -pub fn new_pair(mut input: process::Child, desc: String) - -> (ChildIo, ChildIo) { +pub fn new_pair(mut input: process::Child, desc: String) -> Pair { let stdin = input.stdin .take().expect("ChildIo::pair, no stdin¬"); let stdout = input.stdout.take().expect("ChildIo::pair, no stdout¬"); let wrapper = Arc::new(Mutex::new(ChildWrapper { @@ -57,8 +60,7 @@ pub fn new_pair(mut input: process::Child, desc: String) } #[throws(io::Error)] -pub fn run_pair(mut cmd: process::Command, desc: String) - -> (ChildIo, ChildIo) { +pub fn run_pair(mut cmd: process::Command, desc: String) -> Pair { cmd.stdin (Stdio::piped()); cmd.stdout(Stdio::piped()); new_pair(cmd.spawn()?, desc)