kernel-builder 0.7.6

Select, build and install kernel version from local sources.
Documentation
use std::path::PathBuf;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum BuilderErr {
    #[error("Error retrieving root privileges")]
    NoPrivileges,
    #[error("Missing kernel configuration file: {path}")]
    KernelConfigMissing { path: PathBuf },
    #[error("Missing option in kernel configuration: {0}")]
    KernelConfigMissingOption(String),
    #[error("Error updating kernel config: {details}")]
    KernelConfigUpdateError { details: String },
    #[error("Kernel build failed: {0}")]
    KernelBuildFail(String),
    #[error("Error linking file to {path}: {source}")]
    LinkingFileError {
        source: std::io::Error,
        path: PathBuf,
    },
    #[error("Could not parse config file")]
    ConfigError(#[from] config::ConfigError),
    #[error("Could not create prompt")]
    PromptError(#[from] dialoguer::Error),
    #[error("Error while starting menuconfig")]
    MenuconfigError,
    #[error("Command execution failed: {0}")]
    CommandError(String),
    #[error("Invalid configuration: {0}")]
    InvalidConfig(String),
    #[error("Discovery error: {0}")]
    DiscoveryError(String),
}

impl BuilderErr {
    #[must_use]
    pub fn kernel_config_missing() -> Self {
        Self::KernelConfigMissing {
            path: PathBuf::from("/usr/src/.config"),
        }
    }

    #[must_use]
    pub fn invalid_config(msg: impl Into<String>) -> Self {
        Self::InvalidConfig(msg.into())
    }

    #[must_use]
    pub fn discovery_error(msg: impl Into<String>) -> Self {
        Self::DiscoveryError(msg.into())
    }

    #[must_use]
    pub fn linking_file_error(source: std::io::Error, path: PathBuf) -> Self {
        Self::LinkingFileError { source, path }
    }

    #[must_use]
    pub fn kernel_config_update_error(details: String) -> Self {
        Self::KernelConfigUpdateError { details }
    }
}