Skip to main content

ui_automata/
recovery.rs

1use schemars::JsonSchema;
2use serde::Deserialize;
3
4use crate::{Action, Condition};
5
6/// A domain heuristic that fires when the executor detects a known "lost state".
7#[derive(Clone)]
8pub struct RecoveryHandler {
9    /// Descriptive name shown in logs (e.g. `"dismiss_error_dialog"`).
10    pub name: String,
11
12    /// Condition that identifies this recovery scenario.
13    pub trigger: Condition,
14
15    /// Actions to execute to restore a known-good state.
16    pub actions: Vec<Action>,
17
18    /// What the executor does after the recovery actions complete.
19    pub resume: ResumeStrategy,
20}
21
22/// What the executor does after a recovery handler fires.
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, JsonSchema)]
24#[serde(rename_all = "snake_case")]
25pub enum ResumeStrategy {
26    /// Re-execute the failing step from scratch.
27    RetryStep,
28
29    /// Consider the step already done and advance to the next one.
30    SkipStep,
31
32    /// Treat the step as failed — propagate the error.
33    Fail,
34}