use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BootEntry {
    /// Stable id (also the URL slug in generated iPXE scripts).
    pub id: String,
    /// Display label shown in the iPXE boot menu.
    pub title: String,
    pub kind: BootKind,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum BootKind {
    /// Linux kernel + initrd chainload. Kernel args carry the distro-specific
    /// pointer back to the ISO contents served over HTTP.
    LinuxKernel {
        kernel_url: String,
        initrd_urls: Vec<String>,
        args: KernelArgs,
    },
    /// Windows WinPE boot via wimboot shim. `files` maps in-memory tags to
    /// HTTP URLs the client fetches. See https://ipxe.org/wimboot .
    Wimboot {
        wimboot_url: String,
        files: Vec<(String, String)>,
    },
    /// Last-resort: SAN-boot the ISO as an emulated CD. Only works for small
    /// ISOs (<~1 GiB) and older distros. Kept for completeness, not the
    /// default.
    SanBootIso { iso_url: String },
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct KernelArgs {
    /// Raw kernel command line, already distro-adapted. Do not quote — iPXE
    /// takes a single space-separated command line.
    pub cmdline: String,
}
