Skip to content

Commit

Permalink
fix(crates/server): fix incompatible APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
xrelkd committed Apr 6, 2024
1 parent 329cc98 commit 6bd63ef
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 69 deletions.
61 changes: 7 additions & 54 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ tokio-stream = { version = "0.1", features = ["net"] }
tonic = { version = "0.11", features = ["gzip"] }

zbus = { version = "4", default-features = false, features = ["tokio"] }
zvariant = "3"
zvariant = "4"

hex = "0.4"
humansize = "2"
Expand Down
20 changes: 11 additions & 9 deletions crates/server/src/dbus/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{str::FromStr, sync::Arc};

use clipcat_dbus_variant as dbus_variant;
use tokio::sync::Mutex;
use zbus::dbus_interface;
use zbus::interface;

use crate::{metrics, notification, ClipboardManager};

Expand All @@ -16,7 +16,7 @@ impl<Notification> ManagerService<Notification> {
pub fn new(manager: Arc<Mutex<ClipboardManager<Notification>>>) -> Self { Self { manager } }
}

#[dbus_interface(name = "org.clipcat.clipcat.Manager")]
#[interface(name = "org.clipcat.clipcat.Manager")]
impl<Notification> ManagerService<Notification>
where
Notification: notification::Notification + 'static,
Expand All @@ -35,7 +35,7 @@ where
id
}

#[dbus_interface(property)]
#[zbus(property)]
async fn set_clipboard_text_contents(&self, data: &str) {
metrics::dbus::REQUESTS_TOTAL.inc();
let _histogram_timer = metrics::dbus::REQUEST_DURATION_SECONDS.start_timer();
Expand All @@ -50,7 +50,7 @@ where
drop(manager);
}

#[dbus_interface(property)]
#[zbus(property)]
async fn clipboard_text_contents(&self) -> String {
metrics::dbus::REQUESTS_TOTAL.inc();
let _histogram_timer = metrics::dbus::REQUEST_DURATION_SECONDS.start_timer();
Expand Down Expand Up @@ -86,23 +86,25 @@ where
manager.clear();
}

async fn get(&self, id: u64) -> Option<dbus_variant::ClipEntry> {
async fn get(&self, id: u64) -> zvariant::Optional<dbus_variant::ClipEntry> {
metrics::dbus::REQUESTS_TOTAL.inc();
let _histogram_timer = metrics::dbus::REQUEST_DURATION_SECONDS.start_timer();

let manager = self.manager.lock().await;
manager.get(id).map(Into::into)
zvariant::Optional::from(manager.get(id).map(Into::into))
}

async fn get_current_clip(
&self,
kind: dbus_variant::ClipboardKind,
) -> Option<dbus_variant::ClipEntry> {
) -> zvariant::Optional<dbus_variant::ClipEntry> {
metrics::dbus::REQUESTS_TOTAL.inc();
let _histogram_timer = metrics::dbus::REQUEST_DURATION_SECONDS.start_timer();

let manager = self.manager.lock().await;
manager.get_current_clip(kind.into()).map(|clip| clip.clone().into())
zvariant::Optional::from(
manager.get_current_clip(kind.into()).map(|clip| clip.clone().into()),
)
}

async fn list(&self, preview_length: u64) -> Vec<dbus_variant::ClipEntryMetadata> {
Expand Down Expand Up @@ -137,7 +139,7 @@ where
manager.mark(id, kind.into()).await.is_ok()
}

#[dbus_interface(property)]
#[zbus(property)]
async fn length(&self) -> u64 {
metrics::dbus::REQUESTS_TOTAL.inc();
let _histogram_timer = metrics::dbus::REQUEST_DURATION_SECONDS.start_timer();
Expand Down
6 changes: 3 additions & 3 deletions crates/server/src/dbus/system.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use zbus::dbus_interface;
use zbus::interface;

use crate::metrics;

Expand All @@ -9,10 +9,10 @@ impl SystemService {
pub const fn new() -> Self { Self {} }
}

#[dbus_interface(name = "org.clipcat.clipcat.System")]
#[interface(name = "org.clipcat.clipcat.System")]
impl SystemService {
#[allow(clippy::unused_self)]
#[dbus_interface(property)]
#[zbus(property)]
fn get_version(&self) -> &str {
metrics::dbus::REQUESTS_TOTAL.inc();
let _histogram_timer = metrics::dbus::REQUEST_DURATION_SECONDS.start_timer();
Expand Down
4 changes: 2 additions & 2 deletions crates/server/src/dbus/watcher.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clipcat_dbus_variant as dbus_variant;
use zbus::dbus_interface;
use zbus::interface;

use crate::{metrics, notification, ClipboardWatcherToggle};

Expand All @@ -14,7 +14,7 @@ impl<Notification> WatcherService<Notification> {
}
}

#[dbus_interface(name = "org.clipcat.clipcat.Watcher")]
#[interface(name = "org.clipcat.clipcat.Watcher")]
impl<Notification> WatcherService<Notification>
where
Notification: notification::Notification + 'static,
Expand Down

0 comments on commit 6bd63ef

Please sign in to comment.