proto-reg 0.1.0

Manage custom URL protocols in the Windows registry
//! Error types for the `proto-reg` crate.

/// Errors that can occur while managing protocols.
#[derive(Debug, thiserror::Error)]
pub enum Error {
    /// An I/O operation failed (file or registry access).
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    /// JSON (de)serialization failed.
    #[error("JSON error: {0}")]
    Json(#[from] serde_json::Error),

    /// The protocol name is not a valid URL scheme (RFC 3986).
    #[error(
        "invalid protocol name `{name}`: a scheme must start with a letter \
         and contain only letters, digits, `+`, `-` or `.`"
    )]
    InvalidProtocolName { name: String },

    /// The backup file is missing required fields or has invalid content.
    #[error("invalid backup file: {0}")]
    InvalidBackup(String),

    /// An operation that writes to `HKLM\Software\Classes` requires elevation.
    #[error("administrator privileges are required to modify the registry: {0}")]
    ElevationRequired(String),
}

/// Convenience alias used throughout the crate.
pub type Result<T> = std::result::Result<T, Error>;