#[cfg(feature = "registry")]
pub use oxideav_core::{Error, Result};
#[cfg(not(feature = "registry"))]
mod standalone {
use std::fmt;
#[derive(Debug)]
pub enum Error {
InvalidData(String),
Unsupported(String),
Io(std::io::Error),
Other(String),
}
impl Error {
pub fn invalid(msg: impl Into<String>) -> Self {
Self::InvalidData(msg.into())
}
pub fn unsupported(msg: impl Into<String>) -> Self {
Self::Unsupported(msg.into())
}
pub fn other(msg: impl Into<String>) -> Self {
Self::Other(msg.into())
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::InvalidData(s) => write!(f, "invalid data: {s}"),
Self::Unsupported(s) => write!(f, "unsupported: {s}"),
Self::Io(e) => write!(f, "I/O error: {e}"),
Self::Other(s) => write!(f, "{s}"),
}
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::Io(e) => Some(e),
_ => None,
}
}
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Self::Io(e)
}
}
pub type Result<T> = std::result::Result<T, Error>;
}
#[cfg(not(feature = "registry"))]
pub use standalone::{Error, Result};