From 1d5e98d4ea2c34a2344cbb36b8835e8448c9453b Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Wed, 28 Feb 2024 14:59:34 -0500 Subject: [PATCH] refactor: remove thiserror from dependencies --- Cargo.toml | 6 +++--- src/mime.rs | 15 ++++++++++----- src/text.rs | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fa2e7ad..cd499cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,12 +14,12 @@ rust-version = "1.65.0" libc = "0.2.149" sctk = { package = "smithay-client-toolkit", version = "0.18.0", default-features = false, features = ["calloop"] } wayland-backend = { version = "0.3.0", default_features = false, features = ["client_system"] } -thiserror = "1.0.57" [dev-dependencies] -sctk = { package = "smithay-client-toolkit", version = "0.18.0", default-features = false, features = ["calloop", "xkbcommon"] } -url = "2.5.0" dirs = "5.0.1" +sctk = { package = "smithay-client-toolkit", version = "0.18.0", default-features = false, features = ["calloop", "xkbcommon"] } +thiserror = "1.0.57" +url = "2.5.0" [features] default = ["dlopen"] diff --git a/src/mime.rs b/src/mime.rs index cd538dc..def3947 100644 --- a/src/mime.rs +++ b/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)] diff --git a/src/text.rs b/src/text.rs index 7f21c1d..a092e2b 100644 --- a/src/text.rs +++ b/src/text.rs @@ -18,7 +18,7 @@ impl TryFrom<(Vec, 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)) }