pub trait Present: Serialize {
// Required method
fn present(&self) -> Document;
// Provided methods
fn outcome(&self) -> Outcome { ... }
fn exit_code(&self) -> u8 { ... }
}Available on crate feature
view only.Expand description
A command result that serializes for machines and presents itself to people.
JSON output is self serialized as is. Pretty and colourless output is the
Document that Self::present builds. The two share one value, so they
cannot drift apart.
Required Methods§
Provided Methods§
Sourcefn outcome(&self) -> Outcome
fn outcome(&self) -> Outcome
Whether the result is a success or a failure. It picks the stream of
pretty output (stdout or stderr) and the default exit code. The default
is Outcome::Success.
Sourcefn exit_code(&self) -> u8
fn exit_code(&self) -> u8
The process exit code. The default is 0 for a success and 1 for an
error (Outcome::default_exit_code).
Override it to give a failure its own code, such as a usage error
distinct from an operational failure. The stream still follows
Self::outcome.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".