From 886f43041477e98035e065719c62bdfcae0a7d21 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Thu, 14 Mar 2024 13:16:13 -0400 Subject: [PATCH] refactor: avoid breaking changes and update smithay-clipboard --- src/lib.rs | 24 ++++++++++++------------ src/platform/linux.rs | 32 ++++++++++++++++---------------- wayland/Cargo.toml | 2 +- wayland/src/lib.rs | 16 ++++++++-------- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1385a8d..af880a0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,51 +67,51 @@ impl Clipboard { } pub fn read(&self) -> Result> { - self.raw.read_text() + self.raw.read() } pub fn write(&mut self, contents: String) -> Result<(), Box> { - self.raw.write_text(contents) + self.raw.write(contents) } } impl Clipboard { pub fn read_primary(&self) -> Option>> { - self.raw.read_primary_text() + self.raw.read_primary() } pub fn write_primary( &mut self, contents: String, ) -> Option>> { - self.raw.write_primary_text(contents) + self.raw.write_primary(contents) } } pub trait ClipboardProvider { - fn read_text(&self) -> Result>; + fn read(&self) -> Result>; - fn write_text(&mut self, contents: String) -> Result<(), Box>; + fn write(&mut self, contents: String) -> Result<(), Box>; - fn read_primary_text(&self) -> Option>> { + fn read_primary(&self) -> Option>> { None } - fn write_primary_text( + fn write_primary( &mut self, _contents: String, ) -> Option>> { None } - fn read(&self) -> Option>> + fn read_data(&self) -> Option>> where ClipboardLoadData: platform::InnerAllowedMimeTypes, { None } - fn write( + fn write_data( &mut self, _contents: ClipboardStoreData, ) -> Option>> @@ -121,14 +121,14 @@ pub trait ClipboardProvider { None } - fn read_primary(&self) -> Option>> + fn read_primary_data(&self) -> Option>> where ClipboardLoadData: platform::InnerAllowedMimeTypes, { None } - fn write_primary( + fn write_primary_data( &mut self, _contents: ClipboardStoreData, ) -> Option>> diff --git a/src/platform/linux.rs b/src/platform/linux.rs index 75d65d9..5001852 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -19,53 +19,53 @@ pub enum Clipboard { } impl ClipboardProvider for Clipboard { - fn read_text(&self) -> Result> { + fn read(&self) -> Result> { match self { - Clipboard::Wayland(c) => c.read_text(), + Clipboard::Wayland(c) => c.read(), Clipboard::X11(c) => c.read().map_err(Box::from), } } - fn write_text(&mut self, contents: String) -> Result<(), Box> { + fn write(&mut self, contents: String) -> Result<(), Box> { match self { - Clipboard::Wayland(c) => c.write_text(contents), + Clipboard::Wayland(c) => c.write(contents), Clipboard::X11(c) => c.write(contents).map_err(Box::from), } } - fn read_primary_text(&self) -> Option>> { + fn read_primary(&self) -> Option>> { match self { - Clipboard::Wayland(c) => Some(c.read_primary_text()), + Clipboard::Wayland(c) => Some(c.read_primary()), Clipboard::X11(c) => Some(c.read_primary().map_err(Box::from)), } } - fn write_primary_text( + fn write_primary( &mut self, contents: String, ) -> Option>> { match self { - Clipboard::Wayland(c) => Some(c.write_primary_text(contents)), + Clipboard::Wayland(c) => Some(c.write_primary(contents)), Clipboard::X11(c) => { Some(c.write_primary(contents).map_err(Box::from)) } } } - fn read(&self) -> Option>> + fn read_data(&self) -> Option>> where ClipboardLoadData: InnerAllowedMimeTypes, { match self { Clipboard::Wayland(c) => { - let ret = c.read::>(); + let ret = c.read_data::>(); Some(ret.map(|ret| ret.0)) } Clipboard::X11(_) => None, } } - fn write( + fn write_data( &mut self, contents: ClipboardStoreData, ) -> Option>> @@ -74,26 +74,26 @@ impl ClipboardProvider for Clipboard { { match self { Clipboard::Wayland(c) => { - Some(c.write::>(contents)) + Some(c.write_data::>(contents)) } Clipboard::X11(_) => None, } } - fn read_primary(&self) -> Option>> + fn read_primary_data(&self) -> Option>> where ClipboardLoadData: InnerAllowedMimeTypes, { match self { Clipboard::Wayland(c) => { - let ret = c.read_primary::>(); + let ret = c.read_primary_data::>(); Some(ret.map(|ret| ret.0)) } Clipboard::X11(_) => None, } } - fn write_primary( + fn write_primary_data( &mut self, contents: ClipboardStoreData, ) -> Option>> @@ -102,7 +102,7 @@ impl ClipboardProvider for Clipboard { { match self { Clipboard::Wayland(c) => { - Some(c.write_primary::>(contents)) + Some(c.write_primary_data::>(contents)) } Clipboard::X11(_) => None, } diff --git a/wayland/Cargo.toml b/wayland/Cargo.toml index 9d3ada8..2751f2e 100644 --- a/wayland/Cargo.toml +++ b/wayland/Cargo.toml @@ -10,5 +10,5 @@ documentation = "https://docs.rs/clipboard_wayland" keywords = ["clipboard", "wayland"] [dependencies] -smithay-clipboard = { git = "https://github.com/wash2/smithay-clipboard", branch = "mime-types" } +smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-mime-types" } # smithay-clipboard = { path = "../../smithay-clipboard" } diff --git a/wayland/src/lib.rs b/wayland/src/lib.rs index e4a8b22..fb5bb2e 100644 --- a/wayland/src/lib.rs +++ b/wayland/src/lib.rs @@ -33,21 +33,21 @@ impl Clipboard { Clipboard { context } } - pub fn read_text(&self) -> Result> { + pub fn read(&self) -> Result> { Ok(self.context.lock().unwrap().load_text()?) } - pub fn read_primary_text(&self) -> Result> { + pub fn read_primary(&self) -> Result> { Ok(self.context.lock().unwrap().load_primary_text()?) } - pub fn write_text(&mut self, data: String) -> Result<(), Box> { + pub fn write(&mut self, data: String) -> Result<(), Box> { self.context.lock().unwrap().store_text(data); Ok(()) } - pub fn write_primary_text( + pub fn write_primary( &mut self, data: String, ) -> Result<(), Box> { @@ -56,7 +56,7 @@ impl Clipboard { Ok(()) } - pub fn write( + pub fn write_data( &mut self, data: T, ) -> Result<(), Box> { @@ -65,7 +65,7 @@ impl Clipboard { Ok(()) } - pub fn write_primary( + pub fn write_primary_data( &mut self, data: T, ) -> Result<(), Box> { @@ -74,13 +74,13 @@ impl Clipboard { Ok(()) } - pub fn read( + pub fn read_data( &self, ) -> Result> { Ok(self.context.lock().unwrap().load()?) } - pub fn read_primary( + pub fn read_primary_data( &self, ) -> Result> { Ok(self.context.lock().unwrap().load_primary()?)