refactor: remove thiserror from dependencies
This commit is contained in:
parent
87661a2611
commit
1d5e98d4ea
3 changed files with 14 additions and 9 deletions
15
src/mime.rs
15
src/mime.rs
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue