zlayer-types 0.13.0

Shared wire types for the ZLayer platform — API DTOs, OCI image references, and related serde types.
Documentation
//! Wire types for the toolchain lockfile (`zlayer-toolchains.lock`).
//!
//! These are **pure serde** shapes. The file's load/save/lookup/upsert I/O (TOML
//! on disk, deterministic ordering, sha256 recomputation) lives in
//! `zlayer-toolchain`'s `lockfile` module — this crate only defines the shapes so
//! both `zlayer-toolchain` (which *consumes* a lock during provisioning) and
//! `zlayer-builder` (which will *pass* one through in a later commit) can name
//! them without pulling in `tokio`/`reqwest`.
//!
//! A lock pins one resolved `(tool, platform, arch)` to an exact `version`,
//! download `url`, and `sha256`, so a later provision is reproducible and
//! integrity-checked rather than resolving "latest" afresh.

use serde::{Deserialize, Serialize};

/// Current on-disk schema version for [`ToolchainLockfile`].
pub const TOOLCHAIN_LOCK_SCHEMA: u32 = 1;

/// The parsed toolchain lockfile: a schema tag, a generation timestamp, and the
/// set of pinned tools (serialized as a TOML `[[tool]]` array of tables).
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ToolchainLockfile {
    /// On-disk schema version (see [`TOOLCHAIN_LOCK_SCHEMA`]).
    pub schema: u32,
    /// RFC 3339 timestamp of when the lock was last written.
    pub generated_at: String,
    /// The pinned tools. Serialized/deserialized as `[[tool]]` tables.
    #[serde(default, rename = "tool")]
    pub tools: Vec<LockedTool>,
}

/// One pinned toolchain entry: an exact, integrity-checked resolution.
///
/// `Ord` is derived field-by-field (tool, then platform, then arch, ...), so the
/// natural sort orders entries by `(tool, platform, arch)` first — the ordering
/// the lockfile writer uses for a stable, diff-friendly file.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct LockedTool {
    /// The tool request token as provisioned (e.g. `git`, `node@lts`).
    pub tool: String,
    /// Target platform (`macos` / `windows`).
    pub platform: String,
    /// Host architecture token (`arm64` / `x86_64`).
    pub arch: String,
    /// The exact resolved version (e.g. `2.55.0`).
    pub version: String,
    /// The exact download URL the artifact was fetched from.
    pub url: String,
    /// The artifact's sha256 (bare lowercase hex).
    pub sha256: String,
    /// RFC 3339 timestamp of when this entry was resolved.
    pub resolved_at: String,
}