Skip to content

Commit 250586c

Browse files
committed
Wrap std Output in CommandOutput
1 parent 3fe4d13 commit 250586c

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/bootstrap/src/utils/exec.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,43 +62,44 @@ impl<'a> From<&'a mut Command> for BootstrapCommand<'a> {
6262

6363
/// Represents the output of an executed process.
6464
#[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);
7166

7267
impl CommandOutput {
7368
pub fn is_success(&self) -> bool {
74-
self.status.success()
69+
self.0.status.success()
7570
}
7671

7772
pub fn is_failure(&self) -> bool {
7873
!self.is_success()
7974
}
8075

8176
pub fn status(&self) -> ExitStatus {
82-
self.status
77+
self.0.status
8378
}
8479

8580
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")
8782
}
8883

8984
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![] })
9192
}
9293
}
9394

9495
impl From<Output> for CommandOutput {
9596
fn from(output: Output) -> Self {
96-
Self { status: output.status, stdout: output.stdout, stderr: output.stderr }
97+
Self(output)
9798
}
9899
}
99100

100101
impl From<ExitStatus> for CommandOutput {
101102
fn from(status: ExitStatus) -> Self {
102-
Self { status, stdout: Default::default(), stderr: Default::default() }
103+
Self(Output { status, stdout: vec![], stderr: vec![] })
103104
}
104105
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy