pub struct CommandResult {
pub status: String,
pub command: String,
pub data: Option<Value>,
pub message: Option<String>,
pub code: Option<String>,
pub errors: Vec<String>,
pub warnings: Vec<String>,
pub exit_code: i32,
}Expand description
Result of a CLI command execution
Fields§
§status: StringStatus of the command: “success”, “error”, “validation-failed”
command: StringName of the command that was executed
data: Option<Value>Primary data/output from the command
message: Option<String>Error message (if status is “error”)
code: Option<String>Error code (if status is “error”)
errors: Vec<String>Validation errors (if status is “validation-failed”)
warnings: Vec<String>Warnings that occurred during execution
exit_code: i32Exit code for the process: 0=success, 1=error, 2=validation-failed
Implementations§
Source§impl CommandResult
impl CommandResult
Sourcepub fn success(command: &str, data: Value) -> Self
pub fn success(command: &str, data: Value) -> Self
Create a successful command result with data
Sourcepub fn success_with_warnings(
command: &str,
data: Value,
warnings: Vec<String>,
) -> Self
pub fn success_with_warnings( command: &str, data: Value, warnings: Vec<String>, ) -> Self
Create a successful command result with warnings
Sourcepub fn validation_failed(command: &str, errors: Vec<String>) -> Self
pub fn validation_failed(command: &str, errors: Vec<String>) -> Self
Create a validation failure result
Sourcepub fn from_error(command: &str, error: Error) -> Self
pub fn from_error(command: &str, error: Error) -> Self
Create an error result from an anyhow::Error
Trait Implementations§
Source§impl Clone for CommandResult
impl Clone for CommandResult
Source§fn clone(&self) -> CommandResult
fn clone(&self) -> CommandResult
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CommandResult
impl Debug for CommandResult
Source§impl<'de> Deserialize<'de> for CommandResult
impl<'de> Deserialize<'de> for CommandResult
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CommandResult
impl RefUnwindSafe for CommandResult
impl Send for CommandResult
impl Sync for CommandResult
impl Unpin for CommandResult
impl UnwindSafe for CommandResult
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more