Skip to main content

microvm_runtime/
model.rs

1use std::fmt;
2
3use serde::Serialize;
4
5/// Current lifecycle state of a microVM.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
7#[serde(rename_all = "snake_case")]
8pub enum VmStatus {
9    /// Provisioned but not yet started.
10    Created,
11    /// Actively running.
12    Running,
13    /// Gracefully stopped; can be restarted.
14    Stopped,
15    /// Torn down; terminal state.
16    Destroyed,
17}
18
19impl fmt::Display for VmStatus {
20    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21        match self {
22            Self::Created => f.write_str("created"),
23            Self::Running => f.write_str("running"),
24            Self::Stopped => f.write_str("stopped"),
25            Self::Destroyed => f.write_str("destroyed"),
26        }
27    }
28}
29
30/// Read-only snapshot of a microVM's current state.
31#[derive(Debug, Clone, Serialize)]
32pub struct VmView {
33    /// Unique identifier for this microVM.
34    pub vm_id: String,
35    /// Current lifecycle status.
36    pub status: VmStatus,
37    /// Names of snapshots captured for this VM, in creation order.
38    pub snapshots: Vec<String>,
39}