Skip to content

Commit

Permalink
backend: Pass object path to close
Browse files Browse the repository at this point in the history
This lets the implementer to know on which `Request` `close` was called.
  • Loading branch information
arun-mani-j committed Dec 18, 2024
1 parent 01020d2 commit e5431e7
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions backend-demo/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ pub struct Account;

#[async_trait]
impl RequestImpl for Account {
async fn close(&self) {
tracing::debug!("IN Close()");
async fn close(&self, path: OwnedObjectPath) {
tracing::debug!("IN Close(): {}", path.as_str());
}
}

Expand Down
4 changes: 2 additions & 2 deletions backend-demo/src/screenshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ pub struct Screenshot;

#[async_trait]
impl RequestImpl for Screenshot {
async fn close(&self) {
tracing::debug!("IN Close()");
async fn close(&self, path: OwnedObjectPath) {
tracing::debug!("IN Close(): {}", path.as_str());
}
}

Expand Down
4 changes: 2 additions & 2 deletions backend-demo/src/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pub struct Secret;

#[async_trait]
impl RequestImpl for Secret {
async fn close(&self) {
tracing::debug!("IN Close()");
async fn close(&self, path: OwnedObjectPath) {
tracing::debug!("IN Close(): {}", path.as_str());
}
}

Expand Down
4 changes: 2 additions & 2 deletions backend-demo/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pub struct Settings {

#[async_trait]
impl RequestImpl for Settings {
async fn close(&self) {
tracing::debug!("IN Close()");
async fn close(&self, path: OwnedObjectPath) {
tracing::debug!("IN Close(): {}", path.as_str());
}
}

Expand Down
4 changes: 2 additions & 2 deletions backend-demo/src/wallpaper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ pub struct Wallpaper;

#[async_trait]
impl RequestImpl for Wallpaper {
async fn close(&self) {
tracing::debug!("IN Close()");
async fn close(&self, path: OwnedObjectPath) {
tracing::debug!("IN Close(): {}", path.as_str());
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/backend/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::desktop::Response;

#[async_trait]
pub trait RequestImpl: Send + Sync {
async fn close(&self);
async fn close(&self, path: OwnedObjectPath);
}

pub struct Request {
Expand Down Expand Up @@ -39,9 +39,10 @@ impl Request {
#[cfg(feature = "tracing")]
tracing::debug!("{_method}");
let (fut, abort_handle) = abortable(callback);
let path_clone = path.clone();
let close_cb = || {
tokio::spawn(async move {
RequestImpl::close(&*imp).await;
RequestImpl::close(&*imp, path_clone).await;
});
};
let request = Request::new(close_cb, path.clone(), abort_handle, cnx.clone());
Expand Down

0 comments on commit e5431e7

Please sign in to comment.