hazine 0.2.3

Runs a DuckDB Quack server for DuckLake on localhost, reached through an SSH tunnel.
Documentation
use std::io;
use std::net::SocketAddr;
use std::path::PathBuf;

/// Why hazine could not start or keep DuckDB running.
#[derive(Debug, thiserror::Error)]
pub enum Error {
    /// Quack must listen on localhost: access is through an SSH tunnel only.
    #[error(
        "{addr} is not a loopback address; hazine serves on localhost only \
         (reach it through an SSH tunnel)"
    )]
    NotLoopback { addr: SocketAddr },

    /// The init file is missing or is not a file.
    #[error("init file {}: {source}", path.display())]
    InitFile { path: PathBuf, source: io::Error },

    /// Another process — perhaps a second hazine — already serves the address.
    #[error("something is already listening on {addr}")]
    AddrInUse { addr: SocketAddr },

    /// The DuckDB CLI could not be started at all.
    #[error("starting {}: {source}", program.display())]
    Spawn { program: PathBuf, source: io::Error },

    /// The DuckDB CLI is older than 2.0, or not DuckDB at all.
    #[error("{} is not DuckDB 2.0 or later (it reports {found:?})", program.display())]
    UnsupportedVersion { program: PathBuf, found: String },

    /// DuckDB kept exiting before Quack was listening.
    #[error("DuckDB exited {count} times in a row before Quack was listening; giving up")]
    GaveUp { count: u32 },

    /// `hazine setup` changes the system and must run as root.
    #[error("hazine setup must run as root (try sudo, or --dry-run)")]
    NotRoot,

    /// Something this host or build cannot do.
    #[error("{0}")]
    Unsupported(&'static str),

    /// A setting has a value that cannot be used.
    #[error("{name}: {reason}")]
    InvalidSetting { name: &'static str, reason: String },

    /// A setting or secret was neither given nor found in the existing env
    /// file, and there is no terminal to ask for it.
    #[error(
        "{name} is not set: give it as a flag or environment variable, or run setup in a terminal"
    )]
    MissingSetting { name: String },

    /// A program setup runs failed.
    #[error("{program} failed ({status}): {detail}")]
    Command {
        program: String,
        status: String,
        detail: String,
    },

    /// The SSH tunnel to a hazine server could not be opened or kept.
    #[error("{0}")]
    Tunnel(String),

    /// The DuckLake catalog or data could not be reached with the settings.
    #[error("the lake does not attach with these settings: {0}")]
    LakeCheck(String),

    #[error(transparent)]
    Io(#[from] io::Error),
}