zlayer-toolchain 0.14.1

Runtime toolchain provisioning (macOS Homebrew bottle resolver/installer) for ZLayer
Documentation
//! Error types for the toolchain provisioning subsystem.
//!
//! The variant names (`RegistryError`, `CacheError`, `IoError`) mirror the
//! subset of `zlayer_builder::error::BuildError` this crate bridges to via a
//! `From` impl in the builder, so keg-provisioning errors (source build +
//! prebuilt fetch) flow back through `?` at the builder call sites unchanged.

use thiserror::Error;

/// Errors raised while resolving or installing a runtime toolchain.
#[derive(Debug, Error)]
pub enum ToolchainError {
    /// Registry / download / resolution failure (Homebrew API, GHCR blob pull,
    /// `RepoSources` discovery, archive extraction, …).
    #[error("Registry error: {message}")]
    RegistryError {
        /// Underlying registry error description.
        message: String,
    },

    /// Cache or config-serialisation failure.
    #[error("Cache error: {message}")]
    CacheError {
        /// Underlying cache error description.
        message: String,
    },

    /// A requested capability is not implemented in this wave (e.g. the
    /// Windows toolchain path). Distinct from a panic / `todo!()` so callers
    /// get a clean, matchable error instead of an abort.
    #[error("not implemented: {0}")]
    NotImplemented(String),

    /// A downloaded artifact's sha256 did not match the expected digest (either
    /// a formula `urls.stable.checksum`, an upstream-published digest, or a
    /// lockfile pin). The partial download is deleted before this is returned.
    #[error("digest mismatch for {tool}: expected {expected}, got {actual}")]
    DigestMismatch {
        /// The tool / artifact whose digest failed to verify.
        tool: String,
        /// The expected sha256 (bare lowercase hex).
        expected: String,
        /// The sha256 actually computed over the downloaded bytes.
        actual: String,
    },

    /// Underlying I/O error.
    #[error("IO error: {0}")]
    IoError(#[from] std::io::Error),
}

/// Result alias for toolchain operations.
pub type Result<T, E = ToolchainError> = std::result::Result<T, E>;