arta_async_std/process/
child.rs1use super::{AsyncStdStderr, AsyncStdStdin, AsyncStdStdout};
2use crate::AsyncStdGlobalRuntime;
3use arta::process::RuntimeChild;
4use futures::prelude::Future;
5use std::process::{ExitStatus, Output};
6
7pub struct AsyncStdChild {
9 pub(super) inner: async_std::process::Child,
10}
11
12impl RuntimeChild for AsyncStdChild {
13 type Runtime = AsyncStdGlobalRuntime;
14
15 type Stdin<'a> = AsyncStdStdin<'a>
16 where
17 Self: 'a;
18
19 type Stdout<'a> = AsyncStdStdout<'a>
20 where
21 Self: 'a;
22
23 type Stderr<'a> = AsyncStdStderr<'a>
24 where
25 Self: 'a;
26
27 fn stdin(&mut self) -> Option<Self::Stdin<'_>> {
28 self.inner
29 .stdin
30 .as_mut()
31 .map(|stdin| AsyncStdStdin { inner: stdin })
32 }
33
34 fn stdout(&mut self) -> Option<Self::Stdout<'_>> {
35 self.inner
36 .stdout
37 .as_mut()
38 .map(|stdout| AsyncStdStdout { inner: stdout })
39 }
40
41 fn stderr(&mut self) -> Option<Self::Stderr<'_>> {
42 self.inner
43 .stderr
44 .as_mut()
45 .map(|stderr| AsyncStdStderr { inner: stderr })
46 }
47
48 fn id(&self) -> u32 {
49 self.inner.id()
50 }
51
52 fn kill(&mut self) -> std::io::Result<()> {
53 self.inner.kill()
54 }
55
56 fn output(self) -> impl Future<Output = std::io::Result<Output>> + Send {
57 self.inner.output()
58 }
59
60 fn status(&mut self) -> impl Future<Output = std::io::Result<ExitStatus>> + Send {
61 self.inner.status()
62 }
63
64 fn try_status(&mut self) -> std::io::Result<Option<ExitStatus>> {
65 self.inner.try_status()
66 }
67}