refactor: avoid breaking changes and update smithay-clipboard
This commit is contained in:
parent
6c41143f5c
commit
886f430414
4 changed files with 37 additions and 37 deletions
|
|
@ -19,53 +19,53 @@ pub enum Clipboard {
|
|||
}
|
||||
|
||||
impl ClipboardProvider for Clipboard {
|
||||
fn read_text(&self) -> Result<String, Box<dyn Error>> {
|
||||
fn read(&self) -> Result<String, Box<dyn Error>> {
|
||||
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<dyn Error>> {
|
||||
fn write(&mut self, contents: String) -> Result<(), Box<dyn Error>> {
|
||||
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<Result<String, Box<dyn Error>>> {
|
||||
fn read_primary(&self) -> Option<Result<String, Box<dyn Error>>> {
|
||||
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<Result<(), Box<dyn Error>>> {
|
||||
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<T: 'static>(&self) -> Option<Result<T, Box<dyn Error>>>
|
||||
fn read_data<T: 'static>(&self) -> Option<Result<T, Box<dyn Error>>>
|
||||
where
|
||||
ClipboardLoadData<T>: InnerAllowedMimeTypes,
|
||||
{
|
||||
match self {
|
||||
Clipboard::Wayland(c) => {
|
||||
let ret = c.read::<ClipboardLoadData<T>>();
|
||||
let ret = c.read_data::<ClipboardLoadData<T>>();
|
||||
Some(ret.map(|ret| ret.0))
|
||||
}
|
||||
Clipboard::X11(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn write<T: Send + Sync + 'static>(
|
||||
fn write_data<T: Send + Sync + 'static>(
|
||||
&mut self,
|
||||
contents: ClipboardStoreData<T>,
|
||||
) -> Option<Result<(), Box<dyn Error>>>
|
||||
|
|
@ -74,26 +74,26 @@ impl ClipboardProvider for Clipboard {
|
|||
{
|
||||
match self {
|
||||
Clipboard::Wayland(c) => {
|
||||
Some(c.write::<ClipboardStoreData<T>>(contents))
|
||||
Some(c.write_data::<ClipboardStoreData<T>>(contents))
|
||||
}
|
||||
Clipboard::X11(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn read_primary<T: 'static>(&self) -> Option<Result<T, Box<dyn Error>>>
|
||||
fn read_primary_data<T: 'static>(&self) -> Option<Result<T, Box<dyn Error>>>
|
||||
where
|
||||
ClipboardLoadData<T>: InnerAllowedMimeTypes,
|
||||
{
|
||||
match self {
|
||||
Clipboard::Wayland(c) => {
|
||||
let ret = c.read_primary::<ClipboardLoadData<T>>();
|
||||
let ret = c.read_primary_data::<ClipboardLoadData<T>>();
|
||||
Some(ret.map(|ret| ret.0))
|
||||
}
|
||||
Clipboard::X11(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn write_primary<T: Send + Sync + 'static>(
|
||||
fn write_primary_data<T: Send + Sync + 'static>(
|
||||
&mut self,
|
||||
contents: ClipboardStoreData<T>,
|
||||
) -> Option<Result<(), Box<dyn Error>>>
|
||||
|
|
@ -102,7 +102,7 @@ impl ClipboardProvider for Clipboard {
|
|||
{
|
||||
match self {
|
||||
Clipboard::Wayland(c) => {
|
||||
Some(c.write_primary::<ClipboardStoreData<T>>(contents))
|
||||
Some(c.write_primary_data::<ClipboardStoreData<T>>(contents))
|
||||
}
|
||||
Clipboard::X11(_) => None,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue