refactor: remove thiserror from dependencies

This commit is contained in:
Ashley Wulber 2024-02-28 14:59:34 -05:00
parent 87661a2611
commit 1d5e98d4ea
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
3 changed files with 14 additions and 9 deletions

View file

@ -1,16 +1,21 @@
use std::borrow::Cow;
use thiserror::Error;
use std::{error, fmt};
/// List of allowed mimes.
pub static ALLOWED_TEXT_MIME_TYPES: [&str; 3] =
["text/plain;charset=utf-8", "UTF8_STRING", "text/plain"];
#[derive(Error, Debug)]
pub enum Error {
#[error("Unsupported mime type")]
Unsupported,
#[derive(Debug, Clone, Copy)]
pub struct Error;
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Unsupported mime type")
}
}
impl error::Error for Error {}
/// Mime type supported by clipboard.
#[derive(Clone, Eq, PartialEq, Debug, Default)]
#[repr(u8)]

View file

@ -18,7 +18,7 @@ impl TryFrom<(Vec<u8>, MimeType)> for Text {
let content = match mime_type {
MimeType::TextPlainUtf8 | MimeType::TextPlain => normalize_to_lf(content),
MimeType::Utf8String => content,
MimeType::Other(_) => return Err(Error::Unsupported),
MimeType::Other(_) => return Err(Error),
};
Ok(Text(content))
}