use std::fmt;
#[derive(Debug)]
pub enum Error {
SubmissionFull,
NothingAvailable,
Os(i32),
InvalidParam(&'static str),
Backend(String),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::SubmissionFull => write!(f, "submission queue is full"),
Error::NothingAvailable => write!(f, "no completions available"),
Error::Os(e) => write!(f, "os error: {}", e),
Error::InvalidParam(p) => write!(f, "invalid parameter: {}", p),
Error::Backend(msg) => write!(f, "backend error: {}", msg),
}
}
}
impl std::error::Error for Error {}
impl From<i32> for Error {
fn from(e: i32) -> Self {
Error::Os(e)
}
}
pub type Result<T> = std::result::Result<T, Error>;