nativeshell 0.1.16

NativeShell Rust package
Documentation
use std::fmt::Display;

#[derive(Debug, Clone)]
pub enum PlatformError {
    NotAvailable,
    UnknownError,
    GLibError { message: String },
    OtherError { error: String },
}

pub type PlatformResult<T> = Result<T, PlatformError>;

impl Display for PlatformError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            PlatformError::NotAvailable => {
                write!(f, "Not Available")
            }
            PlatformError::UnknownError => {
                write!(f, "Unknown Error")
            }
            PlatformError::GLibError { message } => {
                write!(f, "GLibError: {}", message)
            }
            PlatformError::OtherError { error } => {
                write!(f, "{}", error)
            }
        }
    }
}

impl std::error::Error for PlatformError {}