Skip to main content

arcbox_migration/
progress.rs

1//! Progress types emitted during migration execution.
2
3/// High-level migration stages.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum MigrationStage {
6    /// Preparing the migration plan.
7    Prepare,
8    /// Stopping source containers blocked on volume migration.
9    StopSourceContainers,
10    /// Importing images.
11    ImportImages,
12    /// Importing volumes.
13    ImportVolumes,
14    /// Recreating networks.
15    RecreateNetworks,
16    /// Recreating containers.
17    RecreateContainers,
18    /// Starting containers that were running on the source.
19    StartContainers,
20    /// Cleaning up temporary resources.
21    Cleanup,
22    /// Migration completed.
23    Complete,
24}
25
26impl MigrationStage {
27    /// Returns a stable string representation.
28    #[must_use]
29    pub const fn as_str(self) -> &'static str {
30        match self {
31            Self::Prepare => "prepare",
32            Self::StopSourceContainers => "stop-source-containers",
33            Self::ImportImages => "import-images",
34            Self::ImportVolumes => "import-volumes",
35            Self::RecreateNetworks => "recreate-networks",
36            Self::RecreateContainers => "recreate-containers",
37            Self::StartContainers => "start-containers",
38            Self::Cleanup => "cleanup",
39            Self::Complete => "complete",
40        }
41    }
42}
43
44/// Progress update emitted during migration execution.
45#[derive(Debug, Clone, PartialEq, Eq)]
46pub struct MigrationProgress {
47    /// Current stage.
48    pub stage: MigrationStage,
49    /// Human-readable detail.
50    pub detail: String,
51    /// Resource kind being processed.
52    pub resource_type: Option<String>,
53    /// Resource name being processed.
54    pub resource_name: Option<String>,
55    /// Current item index (1-based).
56    pub current: Option<u32>,
57    /// Total number of items in the current stage.
58    pub total: Option<u32>,
59}