From 23ac0ffc5b6866a2ea4167a926cb851513fed04c Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Thu, 29 Feb 2024 16:38:12 -0500 Subject: [PATCH] refactor: simplify trait bounds in the public interface --- src/lib.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a87fca8..090505a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,10 +54,7 @@ impl Clipboard { /// Load custom clipboard data. /// /// Load the requested type from a clipboard on the last observed seat. - pub fn load(&self) -> Result - where - , MimeType)>>::Error: std::error::Error + Send + Sync, - { + pub fn load(&self) -> Result { self.load_inner(SelectionTarget::Clipboard) } @@ -72,10 +69,7 @@ impl Clipboard { /// /// Load the requested type from a primary clipboard on the last observed /// seat. - pub fn load_primary(&self) -> Result - where - , MimeType)>>::Error: std::error::Error + Send + Sync, - { + pub fn load_primary(&self) -> Result { self.load_inner(SelectionTarget::Primary) } @@ -115,16 +109,17 @@ impl Clipboard { self.store_primary(Text(text.into())); } - fn load_inner(&self, target: SelectionTarget) -> Result - where - , MimeType)>>::Error: std::error::Error + Send + Sync, - { + fn load_inner(&self, target: SelectionTarget) -> Result { let _ = self.request_sender.send(worker::Command::Load(T::allowed().to_vec(), target)); match self.request_receiver.recv() { Ok(res) => res.and_then(|(data, mime)| { - T::try_from((data, mime)) - .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err)) + T::try_from((data, mime)).map_err(|_| { + std::io::Error::new( + std::io::ErrorKind::Other, + "Failed to load data of the requested type.", + ) + }) }), // The clipboard thread is dead, however we shouldn't crash downstream, // so propogating an error.