torrust_tracker_deployer_lib/application/command_handlers/common/mod.rs
1//! Common utilities for command handlers
2//!
3//! This module provides shared functionality used across multiple command handlers
4//! to reduce code duplication and improve maintainability.
5
6pub mod endpoint_builder;
7pub mod failure_context;
8
9/// Result type for step execution in command handlers
10///
11/// This type alias captures the common pattern used across all command handlers
12/// where step execution can fail with both an error and the step that was being
13/// executed when the failure occurred.
14///
15/// # Type Parameters
16///
17/// * `T` - The success value type (e.g., `Environment<Provisioned>` or `()`)
18/// * `E` - The error type (e.g., `ProvisionCommandHandlerError`)
19/// * `S` - The step type (e.g., `ProvisionStep`)
20///
21/// # Example
22///
23/// ```rust,ignore
24/// fn execute_with_tracking(
25/// &self,
26/// environment: &Environment<Provisioning>,
27/// ) -> StepResult<Environment<Provisioned>, ProvisionCommandHandlerError, ProvisionStep> {
28/// let current_step = ProvisionStep::RenderTemplates;
29/// self.render_templates()
30/// .map_err(|e| (e, current_step))?;
31/// // ... more steps
32/// }
33/// ```
34pub type StepResult<T, E, S> = Result<T, (E, S)>;