Skip to main content

perl_subprocess_runtime/
output.rs

1/// Output from a subprocess execution
2#[derive(Debug, Clone)]
3pub struct SubprocessOutput {
4    /// Standard output bytes
5    pub stdout: Vec<u8>,
6    /// Standard error bytes
7    pub stderr: Vec<u8>,
8    /// Exit status code (0 typically indicates success)
9    pub status_code: i32,
10}
11
12impl SubprocessOutput {
13    /// Returns true if the subprocess exited successfully (status code 0)
14    pub fn success(&self) -> bool {
15        self.status_code == 0
16    }
17
18    /// Returns stdout as a UTF-8 string, lossy converting invalid bytes
19    pub fn stdout_lossy(&self) -> String {
20        String::from_utf8_lossy(&self.stdout).into_owned()
21    }
22
23    /// Returns stderr as a UTF-8 string, lossy converting invalid bytes
24    pub fn stderr_lossy(&self) -> String {
25        String::from_utf8_lossy(&self.stderr).into_owned()
26    }
27}