From 6f67f865800b5fce4fefb664c478505709075dcf Mon Sep 17 00:00:00 2001 From: ranfdev Date: Thu, 21 Nov 2024 16:54:17 +0100 Subject: [PATCH] remove any trace of capnp --- Cargo.lock | 38 ------------------------- Cargo.toml | 2 -- build-aux/com.ranfdev.Notify.Devel.json | 11 ------- src/subscription.rs | 20 ++++++------- src/widgets/advanced_message_dialog.rs | 2 +- 5 files changed, 11 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 71a124d..1c3e0d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -459,36 +459,6 @@ dependencies = [ "system-deps", ] -[[package]] -name = "capnp" -version = "0.18.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "384b671a5b39eadb909b0c2b81d22a400d446526e651e64be9eb6674b33644a4" -dependencies = [ - "embedded-io", -] - -[[package]] -name = "capnp-futures" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8697b857f5b014ff378f02817426d3b6fb90a69f32e330fe010f24fe10cf8f1" -dependencies = [ - "capnp", - "futures", -] - -[[package]] -name = "capnp-rpc" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b87a9e0f74600628e227d39b79ef8652c558a408999ac46ba22b19dbad0010" -dependencies = [ - "capnp", - "capnp-futures", - "futures", -] - [[package]] name = "cbc" version = "0.1.2" @@ -693,12 +663,6 @@ dependencies = [ "syn 2.0.87", ] -[[package]] -name = "embedded-io" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bbadc628dc286b9ae02f0cb0f5411c056eb7487b72f0083203f115de94060" - [[package]] name = "encoding_rs" version = "0.8.35" @@ -1907,8 +1871,6 @@ dependencies = [ "anyhow", "ashpd", "async-channel", - "capnp", - "capnp-rpc", "chrono", "futures", "gettext-rs", diff --git a/Cargo.toml b/Cargo.toml index 069b25a..c12752e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,6 @@ tracing-subscriber = "0.3" adw = { version = "0.7", package = "libadwaita", features = ["v1_6"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -capnp = "0.18.0" -capnp-rpc = "0.18.0" anyhow = "1.0.71" chrono = "0.4.26" rand = "0.8.5" diff --git a/build-aux/com.ranfdev.Notify.Devel.json b/build-aux/com.ranfdev.Notify.Devel.json index 07b9824..5a85fd9 100644 --- a/build-aux/com.ranfdev.Notify.Devel.json +++ b/build-aux/com.ranfdev.Notify.Devel.json @@ -37,17 +37,6 @@ ] }, "modules": [ - { - "name": "capnp", - "buildsystem": "cmake", - "sources": [ - { - "type": "archive", - "url": "https://capnproto.org/capnproto-c++-0.10.4.tar.gz", - "sha256": "981e7ef6dbe3ac745907e55a78870fbb491c5d23abd4ebc04e20ec235af4458c" - } - ] - }, { "name": "blueprint-compiler", "buildsystem": "meson", diff --git a/src/subscription.rs b/src/subscription.rs index e656b30..dcb68c4 100644 --- a/src/subscription.rs +++ b/src/subscription.rs @@ -1,8 +1,8 @@ use std::cell::{Cell, OnceCell, RefCell}; +use std::future::Future; use std::rc::Rc; use adw::prelude::*; -use capnp::capability::Promise; use glib::subclass::prelude::*; use glib::Properties; use gtk::{gio, glib}; @@ -137,9 +137,9 @@ impl Subscription { self._set_display_name(display_name.to_string()); } - fn load(&self) -> Promise<(), capnp::Error> { + fn load(&self) -> impl Future> { let this = self.clone(); - Promise::from_future(async move { + async move { let remote_subscription = this.imp().client.get().unwrap(); let model = remote_subscription.model().await; @@ -161,7 +161,7 @@ impl Subscription { this.handle_event(ev); } Ok(()) - }) + } } fn handle_event(&self, ev: ListenerEvent) { @@ -198,13 +198,13 @@ impl Subscription { self.notify_display_name(); } #[instrument(skip_all)] - pub fn set_display_name(&self, value: String) -> Promise<(), anyhow::Error> { + pub fn set_display_name(&self, value: String) -> impl Future> { let this = self.clone(); - Promise::from_future(async move { + async move { this._set_display_name(value); this.send_updated_info().await?; Ok(()) - }) + } } async fn send_updated_info(&self) -> anyhow::Result<()> { @@ -240,14 +240,14 @@ impl Subscription { self.notify_unread_count(); } - pub fn set_muted(&self, value: bool) -> Promise<(), anyhow::Error> { + pub fn set_muted(&self, value: bool) -> impl Future> { let this = self.clone(); - Promise::from_future(async move { + async move { this.imp().muted.replace(value); this.notify_muted(); this.send_updated_info().await?; Ok(()) - }) + } } pub async fn flag_all_as_read(&self) -> anyhow::Result<()> { let imp = self.imp(); diff --git a/src/widgets/advanced_message_dialog.rs b/src/widgets/advanced_message_dialog.rs index d219dbd..d181eb0 100644 --- a/src/widgets/advanced_message_dialog.rs +++ b/src/widgets/advanced_message_dialog.rs @@ -182,7 +182,7 @@ impl AdvancedMessageDialog { &mut buffer.start_iter(), &mut buffer.end_iter(), true, - )).map_err(|e| capnp::Error::failed(e.to_string()))?; + ))?; thisc.imp().subscription.get().unwrap() .publish_msg(msg).await };