app-info 0.1.1

Get the installed apps and icons on the device
Documentation
use thiserror::Error;

#[derive(Error, Debug)]
pub enum AppInfoError {
    #[error("Failed to read applications directory: {0}")]
    DirectoryReadError(#[from] std::io::Error),

    #[error("I/O error while {action} at {path}: {source}")]
    Io {
        action: &'static str,
        path: String,
        #[source]
        source: std::io::Error,
    },

    #[error("Failed to parse application bundle: {path}")]
    BundleParseError { path: String },

    #[error("Failed to read Info.plist: {0}")]
    PlistError(String),

    #[error("Registry access error: {0}")]
    RegistryError(String),

    #[error("Application not found: {name}")]
    AppNotFound { name: String },

    #[error("Unsupported platform")]
    UnsupportedPlatform,

    #[error("Failed to get file icon: {0}")]
    FileIconError(#[from] FileIconError),
}

#[derive(Error, Debug)]
pub enum FileIconError {
    #[error("Path does not exist")]
    PathDoesNotExist,

    #[error("Icon size cannot be zero")]
    NullIconSize,

    #[error("Icon size {requested} exceeds the maximum supported size of {maximum}")]
    SizeTooLarge { requested: u16, maximum: u16 },

    #[error("Invalid RGBA pixel buffer: expected {expected} bytes, got {actual}")]
    InvalidPixelBuffer { expected: usize, actual: usize },

    #[error("Failed to extract icon: {0}")]
    Failed(String),

    #[error("Platform not supported")]
    PlatformNotSupported,
}

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