diff --git a/mediarepo-api/Cargo.toml b/mediarepo-api/Cargo.toml index 76667f1..61f9c52 100644 --- a/mediarepo-api/Cargo.toml +++ b/mediarepo-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mediarepo-api" -version = "0.19.0" +version = "0.20.0" edition = "2018" license = "gpl-3" @@ -20,7 +20,7 @@ url = {version = "^2.2.2", optional=true } pathsearch = {version="^0.2.0", optional=true} [dependencies.bromine] -version = "^0.16.2" +version = "^0.17.1" optional = true features = ["serialize_bincode"] diff --git a/mediarepo-api/src/client_api/mod.rs b/mediarepo-api/src/client_api/mod.rs index 0bc1564..62b8f93 100644 --- a/mediarepo-api/src/client_api/mod.rs +++ b/mediarepo-api/src/client_api/mod.rs @@ -19,29 +19,23 @@ pub trait IPCApi { fn namespace() -> &'static str; fn ctx(&self) -> PoolGuard; - async fn emit( - &self, - event_name: &str, - data: T, - ) -> ApiResult { + fn emit(&self, event_name: &str, data: T) -> EmitMetadata { let ctx = self.ctx(); - let meta = ctx.emit_to(Self::namespace(), event_name, data).await?; - - Ok(meta) + ctx.emit_to(Self::namespace(), event_name, data) } - async fn emit_and_get( + async fn emit_and_get( &self, event_name: &str, data: T, timeout: Option, ) -> ApiResult { - let mut meta = self.emit(event_name, data).await?; + let mut meta = self.emit(event_name, data).await_reply(); if let Some(timeout) = timeout { meta = meta.with_timeout(timeout); } - let response = meta.await_reply(&self.ctx()).await?; + let response = meta.await?; Ok(response.payload()?) } @@ -108,7 +102,7 @@ impl ApiClient { #[tracing::instrument(level = "debug", skip(self))] pub async fn info(&self) -> ApiResult { let ctx = self.ctx.acquire(); - let res = ctx.emit("info", ()).await?.await_reply(&ctx).await?; + let res = ctx.emit("info", ()).await_reply().await?; Ok(res.payload::()?) } diff --git a/mediarepo-api/src/tauri_plugin/commands/daemon.rs b/mediarepo-api/src/tauri_plugin/commands/daemon.rs index 01bff9d..6d908cd 100644 --- a/mediarepo-api/src/tauri_plugin/commands/daemon.rs +++ b/mediarepo-api/src/tauri_plugin/commands/daemon.rs @@ -57,7 +57,7 @@ async fn try_connect_daemon(address: String) -> IPCResult<()> { .address(address) .build_client() .await?; - ctx.emit("info", ()).await?.await_reply(&ctx).await?; + ctx.emit("info", ()).await_reply().await?; ctx.stop().await?; Ok(()) }