Skip to main content

CommandResult

Struct CommandResult 

Source
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

Source

pub fn new(command: &str, status: CommandStatus, message: &str) -> Self

A result with the given status.

Source

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).

Source

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).

Source

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.

Source

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.

Source

pub fn with_fix(self, fix: Vec<String>) -> Self

The fix lines, replacing the catalog’s.

Source

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.

Source

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.

Source

pub fn with_remedy(self, remedy: Option<Remedy>) -> Self

Attaches the fix speccoder can apply itself.

Source

pub fn remedy(&self) -> Option<&Remedy>

The fix speccoder can apply itself, if it knows one.

Source

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.

Source

pub fn has_explicit_code(&self) -> bool

Whether a code was named explicitly (not the status’s default).

Source

pub fn fix(&self) -> Vec<String>

How to resolve it: the fixes given, else the code’s own.

Source

pub fn with_next(self, next: Vec<NextStep>) -> Self

Attaches what to do next (data.next, the human Next: block).

Source

pub fn next(&self) -> &[NextStep]

What to do next.

Source

pub fn with_data(self, data: CommandData) -> Self

Attaches the command’s payload.

Source

pub fn data(&self) -> Option<&CommandData>

The command’s payload, if any.

Source

pub fn ok(command: &str, message: &str) -> Self

A successful result.

Source

pub fn command(&self) -> &str

The subcommand name, e.g. inspect.

Source

pub fn status(&self) -> CommandStatus

The outcome class.

Source

pub fn message(&self) -> &str

The single-line human-readable message.

Source

pub fn exit_code(&self) -> ExitCode

The process exit status.

Trait Implementations§

Source§

impl Clone for CommandResult

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CommandResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl JsonSchema for CommandResult

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

impl PartialEq for CommandResult

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for CommandResult

Envelope v2: next, code, fix and docs beside the typed data.

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for CommandResult

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.