Struct hermes_cli_framework::output::Output
source · pub struct Output {
pub status: Status,
pub result: Result,
}
Expand description
A CLI output with support for JSON serialization. The only mandatory field is the status
,
which typically signals a success (UNIX process return code 0
) or an error (code 1
). An
optional result
can be added to an output.
Fields§
§status: Status
The return status
result: Result
The result of a command, such as the output from a query or transaction.
Implementations§
source§impl Output
impl Output
sourcepub fn new(status: Status) -> Self
pub fn new(status: Status) -> Self
Constructs a new Output
with the provided status
and an empty result
.
sourcepub fn with_success() -> Self
pub fn with_success() -> Self
Constructor that returns a new Output
having a Success
status and empty result
.
sourcepub fn with_error() -> Self
pub fn with_error() -> Self
Constructor that returns a new Output
having an Error
status and empty result
.
sourcepub fn with_result<R>(self, result: R) -> Self
pub fn with_result<R>(self, result: R) -> Self
Builder-style method for attaching a result to an output object.
sourcepub fn with_msg(self, msg: impl ToString) -> Self
pub fn with_msg(self, msg: impl ToString) -> Self
Builder-style method for attaching a plain text message to an output object.
sourcepub fn success<R>(result: R) -> Self
pub fn success<R>(result: R) -> Self
Quick-access constructor for an output signalling a success status
and tagged with the
input result
.
sourcepub fn error(msg: impl ToString) -> Self
pub fn error(msg: impl ToString) -> Self
Quick-access constructor for an output message signalling a error status
.
sourcepub fn success_msg(msg: impl ToString) -> Self
pub fn success_msg(msg: impl ToString) -> Self
Quick-access constructor for an output signalling a success status
and tagged with the
input result
.