kawaiifi 0.2.0

Wi-Fi scanning library for Linux, macOS, and Windows.
Documentation
use neli::{
    consts::{
        genl::{CtrlAttr, CtrlCmd},
        nl::GenlId,
    },
    err::{MsgError, RouterError, SerError},
    genl::{AttrTypeBuilderError, Genlmsghdr, GenlmsghdrBuilderError, NlattrBuilderError},
    types::Buffer,
};
use thiserror::Error;

use crate::nl80211::{Attr, Cmd};

/// Errors that can occur while scanning for Wi-Fi networks on Linux.
#[derive(Error, Debug)]
pub enum Error {
    /// The scan operation was denied by the operating system.
    #[error("Permission denied")]
    PermissionDenied,

    /// An nl80211 operation failed.
    #[error("Nl80211 error: {0}")]
    Nl80211(String),

    /// A NetworkManager D-Bus operation failed.
    #[error("NetworkManager error: {0}")]
    NetworkManager(#[from] zbus::Error),

    /// The scan completed without returning any scan records.
    #[error("scan did not produce any results")]
    EmptyScan,

    /// An I/O operation failed.
    #[error(transparent)]
    IOError(#[from] std::io::Error),
}

// Internal conversions from neli error types
impl From<MsgError> for Error {
    fn from(err: MsgError) -> Self {
        Error::Nl80211(err.to_string())
    }
}

impl From<SerError> for Error {
    fn from(err: SerError) -> Self {
        Error::Nl80211(err.to_string())
    }
}

impl From<RouterError<u16, Buffer>> for Error {
    fn from(err: RouterError<u16, Buffer>) -> Self {
        Error::Nl80211(err.to_string())
    }
}

impl From<RouterError<GenlId, Genlmsghdr<CtrlCmd, CtrlAttr>>> for Error {
    fn from(err: RouterError<GenlId, Genlmsghdr<CtrlCmd, CtrlAttr>>) -> Self {
        Error::Nl80211(err.to_string())
    }
}

impl From<RouterError<u16, Genlmsghdr<Cmd, Attr>>> for Error {
    fn from(err: RouterError<u16, Genlmsghdr<Cmd, Attr>>) -> Self {
        Error::Nl80211(err.to_string())
    }
}

impl From<AttrTypeBuilderError> for Error {
    fn from(err: AttrTypeBuilderError) -> Self {
        Error::Nl80211(err.to_string())
    }
}

impl From<NlattrBuilderError> for Error {
    fn from(err: NlattrBuilderError) -> Self {
        Error::Nl80211(err.to_string())
    }
}

impl From<GenlmsghdrBuilderError> for Error {
    fn from(err: GenlmsghdrBuilderError) -> Self {
        Error::Nl80211(err.to_string())
    }
}