pub struct CommandResult { /* private fields */ }Expand description
The result of one command, rendered as human text or as one JSON object.
exit_code always equals status.exit_code(): the constructors set it and
the fields are private, so the two can never disagree.
Implementations§
Source§impl CommandResult
impl CommandResult
Sourcepub fn new(command: &str, status: CommandStatus, message: &str) -> Self
pub fn new(command: &str, status: CommandStatus, message: &str) -> Self
A result with the given status.
Sourcepub fn carried(command: &str, from: &Self) -> Self
pub fn carried(command: &str, from: &Self) -> Self
from’s outcome reported as command’s: status, message and code,
without from’s payload (a command passing on a failure it met).
Sourcepub fn caused_by(self, from: &Self) -> Self
pub fn caused_by(self, from: &Self) -> Self
The code, fixes and remedy of from, whose outcome this result
reports with the same status (a feature’s run stopped by a task’s).
Sourcepub fn reworded(self, status: CommandStatus, message: &str) -> Self
pub fn reworded(self, status: CommandStatus, message: &str) -> Self
The same result with another status and message: payload and next steps kept, the code kept only while the status stays the same.
Sourcepub fn with_code(self, name: &str) -> Self
pub fn with_code(self, name: &str) -> Self
Names the code (a catalog name); its fixes become the result’s
unless Self::with_fix gives better ones. An unknown name is
ignored, and the status’s default code applies later.
Sourcepub fn with_commands(self, commands: Vec<Argvs>) -> Self
pub fn with_commands(self, commands: Vec<Argvs>) -> Self
The person’s own commands among the fix lines, as the argvs the
source built (each line crate::step::render of its argvs): run
as these argvs, never re-read from the line.
Sourcepub fn with_command(self, argvs: Argvs) -> Self
pub fn with_command(self, argvs: Argvs) -> Self
A fix that is the person’s own command, built as argvs: its line joins the fixes, the argvs are what runs.
Sourcepub fn with_remedy(self, remedy: Option<Remedy>) -> Self
pub fn with_remedy(self, remedy: Option<Remedy>) -> Self
Attaches the fix speccoder can apply itself.
Sourcepub fn code(&self) -> Option<&'static Entry>
pub fn code(&self) -> Option<&'static Entry>
The code: the one attached, else the status’s default (none for a
plain ok) — no non-ok result is without one.
Sourcepub fn has_explicit_code(&self) -> bool
pub fn has_explicit_code(&self) -> bool
Whether a code was named explicitly (not the status’s default).
Sourcepub fn with_next(self, next: Vec<NextStep>) -> Self
pub fn with_next(self, next: Vec<NextStep>) -> Self
Attaches what to do next (data.next, the human Next: block).
Sourcepub fn with_data(self, data: CommandData) -> Self
pub fn with_data(self, data: CommandData) -> Self
Attaches the command’s payload.
Sourcepub fn data(&self) -> Option<&CommandData>
pub fn data(&self) -> Option<&CommandData>
The command’s payload, if any.
Sourcepub fn status(&self) -> CommandStatus
pub fn status(&self) -> CommandStatus
The outcome class.
Trait Implementations§
Source§impl Clone for CommandResult
impl Clone for CommandResult
Source§impl Debug for CommandResult
impl Debug for CommandResult
Source§impl JsonSchema for CommandResult
impl JsonSchema for CommandResult
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for CommandResult
impl PartialEq for CommandResult
Source§impl Serialize for CommandResult
Envelope v2: next, code, fix and docs beside the typed data.
impl Serialize for CommandResult
Envelope v2: next, code, fix and docs beside the typed data.