Skip to main content

HostTaskResult

Enum HostTaskResult 

Source
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§

§

Passed(TaskSuccess)

§

Failed(TaskFailure)

§

Skipped(TaskSkip)

Implementations§

Source§

impl HostTaskResult

Source

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 - The TaskSuccess containing details about the successful execution, including any results, changes made, warnings, and timing information.
§Returns

A HostTaskResult::Passed variant containing the provided success details.

Source

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 - The TaskFailure containing error information, failure classification, retry hints, and any warnings or messages collected before failure.
§Returns

A HostTaskResult::Failed variant containing the provided failure details.

Source

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).

Source

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 implements Into<String>, such as &str, String, or other string-like types.
§Returns

A HostTaskResult::Skipped variant with the specified reason set.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> HostTaskResult

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HostTaskResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for HostTaskResult

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.