use super::super::types::{CommandOutput, CommandQueueResult, CommandStatus};
impl CommandQueueResult {
#[must_use]
pub fn success(id: String, output: CommandOutput) -> Self {
Self { id, status: CommandStatus::Completed, output: Some(output), error: None }
}
#[must_use]
pub fn failure(id: String, error: String) -> Self {
Self { id, status: CommandStatus::Failed, output: None, error: Some(error) }
}
#[must_use]
pub fn cancelled(id: String) -> Self {
Self {
id,
status: CommandStatus::Cancelled,
output: None,
error: Some("Command was cancelled".to_string()),
}
}
#[must_use]
pub fn is_successful(&self) -> bool {
self.status.is_successful()
}
}