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    /// Cleaning up temporary resources.
19    Cleanup,
20    /// Migration completed.
21    Complete,
22}
23
24impl MigrationStage {
25    /// Returns a stable string representation.
26    #[must_use]
27    pub const fn as_str(self) -> &'static str {
28        match self {
29            Self::Prepare => "prepare",
30            Self::StopSourceContainers => "stop-source-containers",
31            Self::ImportImages => "import-images",
32            Self::ImportVolumes => "import-volumes",
33            Self::RecreateNetworks => "recreate-networks",
34            Self::RecreateContainers => "recreate-containers",
35            Self::Cleanup => "cleanup",
36            Self::Complete => "complete",
37        }
38    }
39}
40
41/// Progress update emitted during migration execution.
42#[derive(Debug, Clone, PartialEq, Eq)]
43pub struct MigrationProgress {
44    /// Current stage.
45    pub stage: MigrationStage,
46    /// Human-readable detail.
47    pub detail: String,
48    /// Resource kind being processed.
49    pub resource_type: Option<String>,
50    /// Resource name being processed.
51    pub resource_name: Option<String>,
52    /// Current item index (1-based).
53    pub current: Option<u32>,
54    /// Total number of items in the current stage.
55    pub total: Option<u32>,
56}