pub struct CapturedOutput { /* private fields */ }Expand description
Captured stdout/stderr from a non-interactive sandbox process.
Wraps a tempfile::TempDir that is automatically removed when the last
Arc<CapturedOutput> is dropped (either from the ProcessCapture handle
or from the ProcessRecord in the registry).
Implementations§
Source§impl CapturedOutput
impl CapturedOutput
Sourcepub fn new(mode: OutputMode) -> Result<Self>
pub fn new(mode: OutputMode) -> Result<Self>
Allocate a new output capture directory.
§Errors
Returns an std::io::Error if the directory cannot be created.
Sourcepub fn stdout_path(&self) -> PathBuf
pub fn stdout_path(&self) -> PathBuf
Path to the stdout output file (or combined output file).
Sourcepub fn stderr_path(&self) -> Option<PathBuf>
pub fn stderr_path(&self) -> Option<PathBuf>
Path to the stderr output file, or None when streams are combined.
Sourcepub fn read_stdout(&self) -> Result<String>
pub fn read_stdout(&self) -> Result<String>
Read captured stdout (or combined output) as a UTF-8 string.
Returns an empty string if the file does not yet exist (process has not produced any output).
§Errors
Returns an std::io::Error if the file exists but cannot be read.
Sourcepub fn read_stderr(&self) -> Result<Option<String>>
pub fn read_stderr(&self) -> Result<Option<String>>
Read captured stderr as a UTF-8 string.
Returns None when using OutputMode::Combined (use
read_stdout instead). Returns an empty string if
the stderr file does not yet exist.
§Errors
Returns an std::io::Error if the file exists but cannot be read.
Sourcepub const fn mode(&self) -> OutputMode
pub const fn mode(&self) -> OutputMode
The capture mode.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CapturedOutput
impl RefUnwindSafe for CapturedOutput
impl Send for CapturedOutput
impl Sync for CapturedOutput
impl Unpin for CapturedOutput
impl UnsafeUnpin for CapturedOutput
impl UnwindSafe for CapturedOutput
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more