pub struct ExecutionResult {
pub raw_output: Vec<u8>,
pub text_output: String,
pub exit_code: Option<i32>,
pub duration: Duration,
pub timed_out: bool,
pub total_bytes: u64,
pub truncated: bool,
}Expand description
Result of command execution.
Fields§
§raw_output: Vec<u8>Raw output from the terminal.
text_output: StringSanitized text output (ANSI codes stripped).
exit_code: Option<i32>Exit code (if command completed).
duration: DurationExecution duration.
timed_out: boolWhether execution timed out.
total_bytes: u64Bytes the command produced, including any this result did not keep.
Counted as the output arrives rather than measured from raw_output,
so it stays accurate once a cap has discarded the tail — which is the
only situation where the two numbers differ, and exactly the situation
a caller needs the real figure for.
truncated: boolWhether output was discarded because it exceeded the cap.
Implementations§
Source§impl ExecutionResult
impl ExecutionResult
Sourcepub fn new(raw_output: Vec<u8>, text_output: String, duration: Duration) -> Self
pub fn new(raw_output: Vec<u8>, text_output: String, duration: Duration) -> Self
Create a new execution result.
total_bytes is taken from raw_output and truncated is false: a
result built this way kept everything it was given. The executor, which
is the only place that can discard output, sets both explicitly through
Self::with_output_extent.
Sourcepub fn timeout(
raw_output: Vec<u8>,
text_output: String,
duration: Duration,
) -> Self
pub fn timeout( raw_output: Vec<u8>, text_output: String, duration: Duration, ) -> Self
Create a result indicating timeout.
Sourcepub fn with_output_extent(self, total_bytes: u64, truncated: bool) -> Self
pub fn with_output_extent(self, total_bytes: u64, truncated: bool) -> Self
Record how much output the command actually produced.
Separate from the constructors because only the collecting loop knows
the figure once a cap is in play — raw_output.len() is what was kept,
not what was produced.
Sourcepub fn with_exit_code(self, code: i32) -> Self
pub fn with_exit_code(self, code: i32) -> Self
Set the exit code.
Sourcepub fn output_trimmed(&self) -> &str
pub fn output_trimmed(&self) -> &str
Get output as string, trimmed.
Sourcepub fn output_lines(&self) -> impl Iterator<Item = &str>
pub fn output_lines(&self) -> impl Iterator<Item = &str>
Get output lines.
Trait Implementations§
Source§impl Clone for ExecutionResult
impl Clone for ExecutionResult
Source§fn clone(&self) -> ExecutionResult
fn clone(&self) -> ExecutionResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more