@@ -62,43 +62,44 @@ impl<'a> From<&'a mut Command> for BootstrapCommand<'a> { |
|
|
62 |
62 |
|
63 |
63 |
/// Represents the output of an executed process. |
64 |
64 |
#[allow(unused)] |
65 |
|
-#[derive(Default)] |
66 |
|
-pub struct CommandOutput { |
67 |
|
-status: ExitStatus, |
68 |
|
-stdout: Vec<u8>, |
69 |
|
-stderr: Vec<u8>, |
70 |
|
-} |
|
65 |
+pub struct CommandOutput(Output); |
71 |
66 |
|
72 |
67 |
impl CommandOutput { |
73 |
68 |
pub fn is_success(&self) -> bool { |
74 |
|
-self.status.success() |
|
69 |
+self.0.status.success() |
75 |
70 |
} |
76 |
71 |
|
77 |
72 |
pub fn is_failure(&self) -> bool { |
78 |
73 |
!self.is_success() |
79 |
74 |
} |
80 |
75 |
|
81 |
76 |
pub fn status(&self) -> ExitStatus { |
82 |
|
-self.status |
|
77 |
+self.0.status |
83 |
78 |
} |
84 |
79 |
|
85 |
80 |
pub fn stdout(&self) -> String { |
86 |
|
-String::from_utf8(self.stdout.clone()).expect("Cannot parse process stdout as UTF-8") |
|
81 |
+String::from_utf8(self.0.stdout.clone()).expect("Cannot parse process stdout as UTF-8") |
87 |
82 |
} |
88 |
83 |
|
89 |
84 |
pub fn stderr(&self) -> String { |
90 |
|
-String::from_utf8(self.stderr.clone()).expect("Cannot parse process stderr as UTF-8") |
|
85 |
+String::from_utf8(self.0.stderr.clone()).expect("Cannot parse process stderr as UTF-8") |
|
86 |
+} |
|
87 |
+} |
|
88 |
+ |
|
89 |
+impl Default for CommandOutput { |
|
90 |
+fn default() -> Self { |
|
91 |
+Self(Output { status: Default::default(), stdout: vec![], stderr: vec![] }) |
91 |
92 |
} |
92 |
93 |
} |
93 |
94 |
|
94 |
95 |
impl From<Output> for CommandOutput { |
95 |
96 |
fn from(output: Output) -> Self { |
96 |
|
-Self { status: output.status, stdout: output.stdout, stderr: output.stderr } |
|
97 |
+Self(output) |
97 |
98 |
} |
98 |
99 |
} |
99 |
100 |
|
100 |
101 |
impl From<ExitStatus> for CommandOutput { |
101 |
102 |
fn from(status: ExitStatus) -> Self { |
102 |
|
-Self { status, stdout: Default::default(), stderr: Default::default() } |
|
103 |
+Self(Output { status, stdout: vec![], stderr: vec![] }) |
103 |
104 |
} |
104 |
105 |
} |