capsid-protocol 0.1.0-alpha.1

Versioned, size-bounded messages between the Capsid host and its guest agent.
Documentation
use serde::{Deserialize, Serialize};

use crate::{AttemptId, CheckpointId};

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)]
pub enum Action {
    Prepare {
        checkpoint: CheckpointId,
    },

    // A restored guest keeps the clock of its capture until the host sets it.
    Bind {
        checkpoint: CheckpointId,

        attempt: AttemptId,

        realtime_ns: u64,

        // The attempt belongs to another instance than the capture, so the
        // guest takes a new machine identity.
        #[serde(default)]
        fork: bool,
    },

    Resume {
        checkpoint: CheckpointId,
    },

    Cancel {
        checkpoint: CheckpointId,
    },
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Phase {
    Preparing,

    Quiesced,

    Bound,

    Running,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Status {
    pub version: u32,

    pub checkpoint: CheckpointId,

    pub source_attempt: AttemptId,

    pub attempt: AttemptId,

    pub phase: Phase,
}