57 lines
1.2 KiB
Rust
57 lines
1.2 KiB
Rust
pub enum LibError {
|
|
IoError(std::io::Error),
|
|
InvalidUrlError(InvalidUrl),
|
|
StatusOutOfRange(u8),
|
|
MessageNotUtf8(std::string::FromUtf8Error),
|
|
InvalidMime(mime::FromStrError),
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|
|
|
|
impl From<mime::FromStrError> for LibError {
|
|
#[inline]
|
|
fn from(err: mime::FromStrError) -> Self {
|
|
Self::InvalidMime(err)
|
|
}
|
|
}
|
|
|
|
pub enum InvalidUrl {
|
|
ParseError(url::ParseError),
|
|
SchemeNotGemini,
|
|
UserinfoPresent,
|
|
NoHostFound,
|
|
ConvertError,
|
|
}
|