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 moreSource§impl Debug for ExecutionResult
impl Debug for ExecutionResult
Auto Trait Implementations§
impl Freeze for ExecutionResult
impl RefUnwindSafe for ExecutionResult
impl Send for ExecutionResult
impl Sync for ExecutionResult
impl Unpin for ExecutionResult
impl UnsafeUnpin for ExecutionResult
impl UnwindSafe for ExecutionResult
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.