use crate::text::InvalidUtf8;
use crate::work::process::{ExitStatusError, Output};
trait Sealed {}
impl Sealed for Output {}
#[doc = crate::_tags!(platform concurrency namespace)]
#[doc = crate::_doc_location!("work/process")]
#[rustfmt::skip]
#[cfg_attr(nightly_doc, doc(notable_trait))]
#[expect(private_bounds, reason = "Sealed")]
pub trait OutputExt: Sealed {
fn stdout_string(self) -> Result<String, InvalidUtf8>;
fn stdout_string_lossy(self) -> String;
fn exit_ok(self) -> Result<Self, ExitStatusError> where Self: Sized;
}
#[rustfmt::skip]
impl OutputExt for Output {
fn stdout_string(self) -> Result<String, InvalidUtf8> {
String::from_utf8(self.stdout).map_err(|e| e.utf8_error().into())
}
fn stdout_string_lossy(self) -> String {
String::from_utf8_lossy(&self.stdout).into_owned()
}
fn exit_ok(self) -> Result<Self, ExitStatusError> {
if self.status.success() { Ok(self) }
else { Err(ExitStatusError { status: self.status }) }
}
}