#[derive(Debug, PartialEq, Eq, thiserror::Error)]
pub enum Error {
#[error(transparent)]
Quiche(#[from] quiche::Error),
#[error("Retry this operation later.")]
Retry,
#[error("Resource is busy.")]
Busy,
#[error("Resource is not found.")]
NotFound,
#[error("Failed to validate client address.")]
ValidateAddress,
}
impl From<Error> for std::io::Error {
fn from(value: Error) -> Self {
match value {
Error::Quiche(error) => std::io::Error::other(error),
Error::Retry | Error::Busy => {
std::io::Error::new(std::io::ErrorKind::WouldBlock, value)
}
Error::NotFound => std::io::Error::new(std::io::ErrorKind::NotFound, value),
Error::ValidateAddress => std::io::Error::other(value),
}
}
}
pub type Result<T> = std::result::Result<T, Error>;