const ERROR_FIRST: u64 = 0x52e4a40fa8db;
const ERROR_LAST: u64 = 0x52e5ac983162;
pub const fn error_from_http3(code: u64) -> Option<u32> {
if code < ERROR_FIRST || code > ERROR_LAST {
return None;
}
let code = code - ERROR_FIRST;
let code = code - code / 0x1f;
Some(code as u32)
}
pub const fn error_to_http3(code: u32) -> u64 {
ERROR_FIRST + code as u64 + code as u64 / 0x1e
}
use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error)]
pub enum Error {
#[error("connection closed")]
Closed,
#[error("invalid url: {0}")]
InvalidUrl(String),
#[error("protocol error: {0}")]
Protocol(String),
#[error("io error: {0}")]
Io(String),
#[error("tls error: {0}")]
Tls(String),
#[error("unsupported: {0}")]
Unsupported(String),
#[error("session error: {0}")]
Session(String),
#[error("other error: {0}")]
Other(String),
}
impl Error {
pub fn other<E: std::fmt::Display>(e: E) -> Self {
Self::Other(e.to_string())
}
}