1use derive_more::Debug;
4use tokio::io::AsyncWrite;
5
6pub type AnyOutput = Output;
7pub type GraphOutput = Output;
8pub type NoOutput = ();
9pub type QueryOutput = Output;
10pub type TextOutput = Output;
11
12#[derive(Debug)]
13pub enum Output {
14 Ignored,
15 Inherited,
16 Captured,
17 AsyncWrite(#[debug(skip)] Box<dyn AsyncWrite + Send + Sync + Unpin>),
18}
19
20impl Output {
21 #[cfg(feature = "std")]
22 pub fn as_stdio(&self) -> std::process::Stdio {
23 use std::process::Stdio;
24 match self {
25 Output::Ignored => Stdio::null(),
26 Output::Inherited => Stdio::inherit(),
27 Output::Captured => Stdio::piped(),
28 Output::AsyncWrite(_) => Stdio::piped(),
29 }
30 }
31}
32
33#[cfg(feature = "std")]
34impl Into<std::process::Stdio> for Output {
35 fn into(self) -> std::process::Stdio {
36 use std::process::Stdio;
37 match self {
38 Output::Ignored => Stdio::null(),
39 Output::Inherited => Stdio::inherit(),
40 Output::Captured => Stdio::piped(),
41 Output::AsyncWrite(_) => Stdio::piped(),
42 }
43 }
44}