feat: add &str utf8 conv error to LibError enum

This commit is contained in:
DarkCat09 2024-08-01 11:59:05 +04:00
parent 9b80902390
commit 2d3a19c60d
Signed by: DarkCat09
GPG key ID: 0A26CD5B3345D6E3

View file

@ -4,6 +4,7 @@ pub enum LibError {
InvalidUrlError(InvalidUrl), InvalidUrlError(InvalidUrl),
StatusOutOfRange(u8), StatusOutOfRange(u8),
MessageNotUtf8(std::string::FromUtf8Error), MessageNotUtf8(std::string::FromUtf8Error),
BodyNotUtf8(std::str::Utf8Error),
InvalidMime(mime::FromStrError), InvalidMime(mime::FromStrError),
} }
@ -42,6 +43,13 @@ impl From<std::string::FromUtf8Error> for LibError {
} }
} }
impl From<std::str::Utf8Error> for LibError {
#[inline]
fn from(err: std::str::Utf8Error) -> Self {
Self::BodyNotUtf8(err)
}
}
impl From<mime::FromStrError> for LibError { impl From<mime::FromStrError> for LibError {
#[inline] #[inline]
fn from(err: mime::FromStrError) -> Self { fn from(err: mime::FromStrError) -> Self {