Update bromine version

Signed-off-by: Trivernis <trivernis@protonmail.com>
pull/4/head
Trivernis 3 years ago
parent 60fdcb5d74
commit ac3bc9cffd

@ -1,6 +1,6 @@
[package] [package]
name = "mediarepo-api" name = "mediarepo-api"
version = "0.19.0" version = "0.20.0"
edition = "2018" edition = "2018"
license = "gpl-3" license = "gpl-3"
@ -20,7 +20,7 @@ url = {version = "^2.2.2", optional=true }
pathsearch = {version="^0.2.0", optional=true} pathsearch = {version="^0.2.0", optional=true}
[dependencies.bromine] [dependencies.bromine]
version = "^0.16.2" version = "^0.17.1"
optional = true optional = true
features = ["serialize_bincode"] features = ["serialize_bincode"]

@ -19,29 +19,23 @@ pub trait IPCApi {
fn namespace() -> &'static str; fn namespace() -> &'static str;
fn ctx(&self) -> PoolGuard<Context>; fn ctx(&self) -> PoolGuard<Context>;
async fn emit<T: IntoPayload + Send>( fn emit<T: IntoPayload + Send>(&self, event_name: &str, data: T) -> EmitMetadata<T> {
&self,
event_name: &str,
data: T,
) -> ApiResult<EmitMetadata> {
let ctx = self.ctx(); let ctx = self.ctx();
let meta = ctx.emit_to(Self::namespace(), event_name, data).await?; ctx.emit_to(Self::namespace(), event_name, data)
Ok(meta)
} }
async fn emit_and_get<T: IntoPayload + Send, R: FromPayload + Send>( async fn emit_and_get<T: IntoPayload + Send + Sync + 'static, R: FromPayload + Send>(
&self, &self,
event_name: &str, event_name: &str,
data: T, data: T,
timeout: Option<Duration>, timeout: Option<Duration>,
) -> ApiResult<R> { ) -> ApiResult<R> {
let mut meta = self.emit(event_name, data).await?; let mut meta = self.emit(event_name, data).await_reply();
if let Some(timeout) = timeout { if let Some(timeout) = timeout {
meta = meta.with_timeout(timeout); meta = meta.with_timeout(timeout);
} }
let response = meta.await_reply(&self.ctx()).await?; let response = meta.await?;
Ok(response.payload()?) Ok(response.payload()?)
} }
@ -108,7 +102,7 @@ impl ApiClient {
#[tracing::instrument(level = "debug", skip(self))] #[tracing::instrument(level = "debug", skip(self))]
pub async fn info(&self) -> ApiResult<InfoResponse> { pub async fn info(&self) -> ApiResult<InfoResponse> {
let ctx = self.ctx.acquire(); 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::<InfoResponse>()?) Ok(res.payload::<InfoResponse>()?)
} }

@ -57,7 +57,7 @@ async fn try_connect_daemon(address: String) -> IPCResult<()> {
.address(address) .address(address)
.build_client() .build_client()
.await?; .await?;
ctx.emit("info", ()).await?.await_reply(&ctx).await?; ctx.emit("info", ()).await_reply().await?;
ctx.stop().await?; ctx.stop().await?;
Ok(()) Ok(())
} }

Loading…
Cancel
Save