pub struct ExecResult {
pub code: i64,
pub out: String,
pub err: String,
pub data: Option<Value>,
pub output: Option<OutputData>,
}Expand description
The result of executing a command or pipeline.
Fields accessible via ${?.field}:
code— exit code (0 = success)ok— true if code == 0err— error message if failedout— raw stdout as stringdata— parsed JSON from stdout (if valid JSON)
Fields§
§code: i64Exit code. 0 means success.
out: StringRaw standard output as a string (canonical for pipes).
err: StringRaw standard error as a string.
data: Option<Value>Parsed JSON data from stdout, if stdout was valid JSON.
output: Option<OutputData>Structured output data for rendering.
Implementations§
Source§impl ExecResult
impl ExecResult
Sourcepub fn with_output(output: OutputData) -> Self
pub fn with_output(output: OutputData) -> Self
Create a successful result with structured output data.
This is the preferred constructor for new code. The OutputData
provides a unified model for all output types.
Sourcepub fn success_data(data: Value) -> Self
pub fn success_data(data: Value) -> Self
Create a successful result with structured data.
Sourcepub fn success_with_data(out: impl Into<String>, data: Value) -> Self
pub fn success_with_data(out: impl Into<String>, data: Value) -> Self
Create a successful result with both text output and structured data.
Use this when a command should have:
- Text output for pipes and traditional shell usage
- Structured data for iteration and programmatic access
The data field takes precedence for command substitution in contexts
like for i in $(cmd) where the structured data can be iterated.
Sourcepub fn failure(code: i64, err: impl Into<String>) -> Self
pub fn failure(code: i64, err: impl Into<String>) -> Self
Create a failed result with an error message.
Trait Implementations§
Source§impl Clone for ExecResult
impl Clone for ExecResult
Source§fn clone(&self) -> ExecResult
fn clone(&self) -> ExecResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExecResult
impl Debug for ExecResult
Source§impl Default for ExecResult
impl Default for ExecResult
Source§impl From<ExecResult> for ControlFlow
impl From<ExecResult> for ControlFlow
Source§fn from(result: ExecResult) -> Self
fn from(result: ExecResult) -> Self
Source§impl From<ExecResult> for ToolResult
impl From<ExecResult> for ToolResult
Source§fn from(exec: ExecResult) -> Self
fn from(exec: ExecResult) -> Self
Source§impl PartialEq for ExecResult
impl PartialEq for ExecResult
impl StructuralPartialEq for ExecResult
Auto Trait Implementations§
impl Freeze for ExecResult
impl RefUnwindSafe for ExecResult
impl Send for ExecResult
impl Sync for ExecResult
impl Unpin for ExecResult
impl UnwindSafe for ExecResult
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> 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