2024-07-31 21:14:29 +03:00
|
|
|
pub enum LibError {
|
|
|
|
IoError(std::io::Error),
|
|
|
|
InvalidUrlError(InvalidUrl),
|
|
|
|
StatusOutOfRange(u8),
|
|
|
|
MessageNotUtf8(std::string::FromUtf8Error),
|
2024-08-01 09:29:34 +03:00
|
|
|
InvalidMime(mime::FromStrError),
|
2024-07-31 21:14:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<std::io::Error> for LibError {
|
|
|
|
#[inline]
|
|
|
|
fn from(err: std::io::Error) -> Self {
|
|
|
|
Self::IoError(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<url::ParseError> for LibError {
|
|
|
|
#[inline]
|
|
|
|
fn from(err: url::ParseError) -> Self {
|
|
|
|
Self::InvalidUrlError(InvalidUrl::ParseError(err))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<InvalidUrl> for LibError {
|
|
|
|
#[inline]
|
|
|
|
fn from(err: InvalidUrl) -> Self {
|
|
|
|
Self::InvalidUrlError(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl LibError {
|
|
|
|
#[inline]
|
|
|
|
pub fn status_out_of_range(num: u8) -> Self {
|
|
|
|
Self::StatusOutOfRange(num)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<std::string::FromUtf8Error> for LibError {
|
|
|
|
#[inline]
|
|
|
|
fn from(err: std::string::FromUtf8Error) -> Self {
|
|
|
|
Self::MessageNotUtf8(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-01 09:29:34 +03:00
|
|
|
impl From<mime::FromStrError> for LibError {
|
|
|
|
#[inline]
|
|
|
|
fn from(err: mime::FromStrError) -> Self {
|
|
|
|
Self::InvalidMime(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-31 21:14:29 +03:00
|
|
|
pub enum InvalidUrl {
|
|
|
|
ParseError(url::ParseError),
|
|
|
|
SchemeNotGemini,
|
|
|
|
UserinfoPresent,
|
|
|
|
NoHostFound,
|
|
|
|
ConvertError,
|
|
|
|
}
|