use core::fmt;
pub type Result<T> = core::result::Result<T, Error>;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum Error {
EmptyStack,
NoStack,
NoVariables,
Unavailable(&'static str),
Truncated,
OutOfMemory,
UnsupportedApiVersion {
found: i32,
required: i32,
},
Failed,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::EmptyStack => f.write_str("stack is empty"),
Self::NoStack => f.write_str("installer passed a null stack pointer"),
Self::NoVariables => f.write_str("installer passed a null variables array"),
Self::Unavailable(what) => write!(f, "installer did not provide `{what}`"),
Self::Truncated => f.write_str("value did not fit in the installer's string_size"),
Self::OutOfMemory => f.write_str("GlobalAlloc failed"),
Self::UnsupportedApiVersion { found, required } => write!(
f,
"installer plug-in API version {found:#010x} is older than the required {required:#010x}"
),
Self::Failed => f.write_str("plug-in reported failure"),
}
}
}
impl core::error::Error for Error {}