use std::fmt;
#[derive(Debug)]
#[non_exhaustive]
pub enum Error {
Unsupported,
LibraryLoad(String),
Backend(String),
Disconnected,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Unsupported => f.write_str("tray is not supported in this environment"),
Error::LibraryLoad(msg) => write!(f, "failed to load platform library: {msg}"),
Error::Backend(msg) => write!(f, "tray backend error: {msg}"),
Error::Disconnected => f.write_str("tray event loop is no longer running"),
}
}
}
impl std::error::Error for Error {}
pub type Result<T> = std::result::Result<T, Error>;