iwconf-win 0.1.2

A colorful, iwconfig-style WLAN CLI for Windows, backed by the native WLAN API (no netsh required).
use thiserror::Error;

/// Every failure mode `iwconf` can hit, from a missing adapter to a raw
/// WLAN API status code. Kept flat and specific on purpose: the CLI layer
/// maps each variant to a distinct exit code and a human, colored message.
///
/// A few variants are only ever constructed on the `cfg(not(windows))`
/// stub path, or are reserved for call sites not wired up yet (e.g. no
/// current command needs to assert "must be connected first"). Clippy's
/// dead-code pass runs per-target and can't see across `cfg` branches, so
/// it flags these on a pure-Windows build; `allow` is correct here rather
/// than deleting variants that are part of the intended error surface.
#[derive(Debug, Error)]
#[allow(dead_code)]
pub enum IwconfError {
    #[error("this build only supports Windows (built native WLAN API bindings are Windows-only)")]
    UnsupportedPlatform,

    #[error("no wireless interfaces were found on this system")]
    NoInterfaces,

    #[error("no interface matches pattern '{0}'")]
    NoInterfaceMatch(String),

    #[error("pattern '{pattern}' matches {count} interfaces, please narrow it: {names}")]
    AmbiguousInterface {
        pattern: String,
        count: usize,
        names: String,
    },

    #[error("interface '{0}' is not connected to any network")]
    NotConnected(String),

    #[error("WLAN API call '{call}' failed with status {code} (0x{code:08X})")]
    WlanApi { call: &'static str, code: u32 },

    #[error("failed to open a handle to the WLAN service (is 'WLAN AutoConfig' running?)")]
    ServiceUnavailable,

    #[error("network '{0}' was not found in the scan results for this interface")]
    NetworkNotFound(String),

    #[error("a passphrase is required to connect to a secured network")]
    MissingPassphrase,

    #[error("connect attempt to '{0}' timed out")]
    ConnectTimeout(String),

    #[error("config error: {0}")]
    Config(#[from] config_get::ConfigError),

    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    #[error("{0}")]
    Other(String),
}

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