byokey-daemon 1.2.0

Bring Your Own Keys — AI subscription-to-API proxy gateway
Documentation
use std::path::PathBuf;

/// Daemon-specific error type.
#[derive(Debug, thiserror::Error)]
pub enum DaemonError {
    #[error("byokey is already running (pid {pid})")]
    AlreadyRunning { pid: u32 },

    #[error("byokey is not running (PID file not found)")]
    NotRunning,

    #[error("failed to stop process {pid}")]
    StopFailed { pid: u32 },

    #[error("failed to spawn daemon process")]
    SpawnFailed(#[source] std::io::Error),

    #[error("I/O error on {path}")]
    Io {
        path: PathBuf,
        #[source]
        source: std::io::Error,
    },

    #[error("cannot determine home directory")]
    NoHomeDir,

    #[error("autostart is not enabled")]
    AutostartNotEnabled,

    #[error("{tool} failed")]
    ServiceToolFailed { tool: &'static str },

    #[error("service is not installed")]
    ServiceNotInstalled,

    #[error("control request failed: {msg}")]
    ControlFailed { msg: String },

    #[error("malformed PID file: {raw}")]
    MalformedPidFile { raw: String },

    #[error("autostart is not supported on this platform")]
    PlatformUnsupported,
}

pub type Result<T> = std::result::Result<T, DaemonError>;