pub enum HostTaskResult {
Passed(TaskSuccess),
Failed(TaskFailure),
Skipped(TaskSkip),
}Expand description
Represents the execution outcome of a task on a single host.
HostTaskResult captures one of three possible states for a task execution:
- Passed: The task completed successfully, potentially with changes, warnings, or metadata.
- Failed: The task encountered an error and could not complete successfully.
- Skipped: The task was not executed, typically due to conditional logic or dependencies.
This enum provides a type-safe way to represent task outcomes and includes helper methods to query the result state and extract the underlying success, failure, or skip details.
§Variants
-
Passed(TaskSuccess)- The task executed successfully. Contains detailed information about the execution including any results, changes made, warnings, and timing information. -
Failed(TaskFailure)- The task failed during execution. Contains error information, failure classification, retry hints, and any warnings or messages collected before failure. -
Skipped(TaskSkip)- The task was skipped and not executed. Contains optional reason and message explaining why the task was skipped.
§Example
use genja_core::task::{HostTaskResult, TaskSuccess, TaskFailure};
// Create a successful result
let success = HostTaskResult::passed(
TaskSuccess::new()
.with_changed(true)
.with_summary("Configuration updated")
);
// Check the result state
assert!(success.is_passed());
assert!(!success.is_failed());
// Extract success details
if let Some(details) = success.success() {
assert!(details.changed());
}
// Create a skipped result
let skipped = HostTaskResult::skipped_with_reason("Host in maintenance mode");
assert!(skipped.is_skipped());Variants§
Implementations§
Source§impl HostTaskResult
impl HostTaskResult
Sourcepub fn passed(result: TaskSuccess) -> Self
pub fn passed(result: TaskSuccess) -> Self
Creates a new HostTaskResult representing a successful task execution.
This constructor wraps a TaskSuccess instance in the Passed variant,
indicating that the task completed successfully on the host.
§Parameters
result- TheTaskSuccesscontaining details about the successful execution, including any results, changes made, warnings, and timing information.
§Returns
A HostTaskResult::Passed variant containing the provided success details.
Sourcepub fn failed(failure: TaskFailure) -> Self
pub fn failed(failure: TaskFailure) -> Self
Creates a new HostTaskResult representing a failed task execution.
This constructor wraps a TaskFailure instance in the Failed variant,
indicating that the task encountered an error and could not complete successfully.
§Parameters
failure- TheTaskFailurecontaining error information, failure classification, retry hints, and any warnings or messages collected before failure.
§Returns
A HostTaskResult::Failed variant containing the provided failure details.
Sourcepub fn skipped() -> Self
pub fn skipped() -> Self
Creates a new HostTaskResult representing a skipped task execution.
This constructor creates a Skipped variant with default (empty) skip details,
indicating that the task was not executed on the host.
§Returns
A HostTaskResult::Skipped variant with default skip information (no reason or message).
Sourcepub fn skipped_with_reason(reason: impl Into<String>) -> Self
pub fn skipped_with_reason(reason: impl Into<String>) -> Self
Creates a new HostTaskResult representing a skipped task execution with a reason.
This constructor creates a Skipped variant with a specified reason explaining
why the task was not executed on the host.
§Parameters
reason- A machine-readable reason code or identifier explaining why the task was skipped. Can be any type that implementsInto<String>, such as&str,String, or other string-like types.
§Returns
A HostTaskResult::Skipped variant with the specified reason set.
Sourcepub fn is_passed(&self) -> bool
pub fn is_passed(&self) -> bool
Checks if the task execution passed (completed successfully).
§Returns
true if this result represents a successful task execution (Passed variant),
false otherwise.
Sourcepub fn is_failed(&self) -> bool
pub fn is_failed(&self) -> bool
Checks if the task execution failed.
§Returns
true if this result represents a failed task execution (Failed variant),
false otherwise.
Sourcepub fn is_skipped(&self) -> bool
pub fn is_skipped(&self) -> bool
Checks if the task execution was skipped.
§Returns
true if this result represents a skipped task execution (Skipped variant),
false otherwise.
Sourcepub fn success(&self) -> Option<&TaskSuccess>
pub fn success(&self) -> Option<&TaskSuccess>
Retrieves the success details if the task passed.
This method extracts the TaskSuccess from a Passed variant, providing
access to execution results, changes, warnings, and other success metadata.
§Returns
Some(&TaskSuccess) if this is a Passed result, None if the task failed
or was skipped.
Sourcepub fn failure(&self) -> Option<&TaskFailure>
pub fn failure(&self) -> Option<&TaskFailure>
Retrieves the failure details if the task failed.
This method extracts the TaskFailure from a Failed variant, providing
access to error information, failure classification, and retry hints.
§Returns
Some(&TaskFailure) if this is a Failed result, None if the task passed
or was skipped.
Sourcepub fn skipped_detail(&self) -> Option<&TaskSkip>
pub fn skipped_detail(&self) -> Option<&TaskSkip>
Retrieves the skip details if the task was skipped.
This method extracts the TaskSkip from a Skipped variant, providing
access to the reason and message explaining why the task was not executed.
§Returns
Some(&TaskSkip) if this is a Skipped result, None if the task passed
or failed.
Trait Implementations§
Source§impl Clone for HostTaskResult
impl Clone for HostTaskResult
Source§fn clone(&self) -> HostTaskResult
fn clone(&self) -> HostTaskResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more