mxc-sdk 1.1.0

Importable library for starting MXC sandboxes in-process, with streaming stdio.
Documentation
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use super::experimental::{OneShotHyperlight, OneShotWindowsSandbox, TestFeature};
use super::network::Network;
use super::primitives::OptionalField;
use super::stable::{
    Fallback, Filesystem, Lifecycle, Lxc, Process, ProcessContainer, RuntimeConfig, Seatbelt,
    Telemetry, Ui,
};
use super::wslc::OneShotWslc;
use crate::mxc_contract::dev::Version;

string_enum! {
    /// Containment selections available in `1.1.0-alpha`.
    #[derive(Debug)]
    pub enum Containment, schema_name = "OneShotContainment" {
        // Stable-candidate values.
        /// Select the host's native process-containment backend.
        Process => ["process"],
        /// Select the Windows ProcessContainer backend.
        ProcessContainer => ["processcontainer"],
        /// Select the Linux LXC backend.
        Lxc => ["lxc"],
        /// Select the Linux Bubblewrap backend.
        Bubblewrap => ["bubblewrap"],
        /// Select the macOS Seatbelt backend.
        Seatbelt => ["seatbelt"],

        // Development-only values.
        /// Select the host's VM-class containment backend.
        Vm => ["vm"],
        /// Select the Windows Sandbox backend.
        WindowsSandbox => ["windows_sandbox"],
        /// Select the NanVix micro-VM backend.
        Microvm => ["microvm"],
        /// Select the Hyperlight micro-VM backend.
        Hyperlight => ["hyperlight"],

        // Stable values introduced in `0.9.0-alpha`.
        /// Select the WSL container backend.
        Wslc => ["wslc"],
        /// Select the Windows IsolationSession backend.
        IsolationSession => ["isolation_session"],
    }
}

/// A complete one-shot `1.1.0-alpha` configuration request.
#[derive(Debug, serde::Deserialize)]
#[cfg_attr(feature = "schema-gen", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "schema-gen", schemars(rename = "OneShotRequest"))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Request {
    /// Optional JSON Schema reference for editor validation.
    #[serde(rename = "$schema", default)]
    pub schema: OptionalField<String>,
    /// Optional human-readable annotation ignored by the runtime.
    #[serde(rename = "_comment", default)]
    pub comment: OptionalField<serde_json::Value>,
    /// The exact contract version marker.
    pub version: Version,
    /// Optional externally assigned container identifier.
    #[serde(default)]
    pub container_id: OptionalField<String>,
    /// Optional containment selection.
    #[serde(default)]
    pub containment: OptionalField<Containment>,
    /// Optional lifecycle settings.
    #[serde(default)]
    pub lifecycle: OptionalField<Lifecycle>,
    /// The process to execute.
    pub process: Process,
    /// Optional filesystem policy.
    #[serde(default)]
    pub filesystem: OptionalField<Filesystem>,
    /// Legacy settings accepted for 1.x compatibility and ignored.
    #[serde(default)]
    pub fallback: OptionalField<Fallback>,
    /// Optional network policy.
    #[serde(default)]
    pub network: OptionalField<Network>,
    /// Optional cross-platform user-interface policy.
    #[serde(default)]
    pub ui: OptionalField<Ui>,
    /// Optional ProcessContainer settings.
    #[serde(default)]
    pub process_container: OptionalField<ProcessContainer>,
    /// Optional LXC distribution settings.
    #[serde(default)]
    pub lxc: OptionalField<Lxc>,
    /// Optional macOS Seatbelt configuration.
    #[serde(default)]
    pub seatbelt: OptionalField<Seatbelt>,
    /// Optional runtime configuration settings.
    #[serde(default)]
    pub runtime_config: OptionalField<RuntimeConfig>,
    /// Optional telemetry configuration.
    #[serde(default)]
    pub telemetry: OptionalField<Telemetry>,
    /// Optional placeholder development feature.
    #[serde(default)]
    pub test: OptionalField<TestFeature>,
    /// Optional one-shot Windows Sandbox compatibility settings.
    #[serde(default)]
    pub windows_sandbox: OptionalField<OneShotWindowsSandbox>,
    /// Optional one-shot WSLC backend settings.
    #[serde(default)]
    pub wslc: OptionalField<OneShotWslc>,
    /// Optional one-shot Hyperlight backend settings.
    #[serde(default)]
    pub hyperlight: OptionalField<OneShotHyperlight>,
    /// Required image selection when containment is MicroVM.
    #[serde(default)]
    pub microvm: OptionalField<OneShotMicroVm>,
}

/// Creation settings for the development MicroVM backend.
#[derive(Debug, serde::Deserialize)]
#[cfg_attr(feature = "schema-gen", derive(schemars::JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct OneShotMicroVm {
    /// Image reference including its registry, resolved by the signed NVX agent.
    pub image: super::ImageReference,
    /// Optional settings applied when creating the MicroVM.
    #[serde(default)]
    pub provision: super::OptionalField<super::MicroVmProvision>,
}