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 more