Skip to content

Commit

Permalink
backend: Remove unnecessary Boxing
Browse files Browse the repository at this point in the history
  • Loading branch information
bilelmoussaoui committed Aug 11, 2024
1 parent 43afc2c commit 6e05363
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
10 changes: 5 additions & 5 deletions src/backend/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ pub trait AccessImpl: RequestImpl {
}

pub struct AccessInterface {
imp: Arc<Box<dyn AccessImpl>>,
imp: Arc<dyn AccessImpl>,
cnx: zbus::Connection,
}

impl AccessInterface {
pub fn new(imp: impl AccessImpl + 'static, cnx: zbus::Connection) -> Self {
Self {
imp: Arc::new(Box::new(imp)),
imp: Arc::new(imp),
cnx,
}
}
Expand Down Expand Up @@ -110,16 +110,16 @@ impl AccessInterface {
let window_identifier = WindowIdentifierType::from_maybe_str(window_identifier);
let app_id = AppID::from_maybe_str(app_id);

let imp: Arc<Box<dyn AccessImpl>> = Arc::clone(&self.imp);
let imp = Arc::clone(&self.imp);
let (fut, request_handle) = abortable(async {
imp.access_dialog(app_id, window_identifier, title, subtitle, body, options)
.await
});

let imp_request = Arc::clone(&self.imp);
let imp = Arc::clone(&self.imp);
let close_cb = || {
tokio::spawn(async move {
RequestImpl::close(&**imp_request).await;
RequestImpl::close(&*imp).await;
});
};
let request = Request::new(close_cb, handle.clone(), request_handle, self.cnx.clone());
Expand Down
10 changes: 5 additions & 5 deletions src/backend/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ pub trait AccountImpl: RequestImpl {
}

pub struct AccountInterface {
imp: Arc<Box<dyn AccountImpl>>,
imp: Arc<dyn AccountImpl>,
cnx: zbus::Connection,
}

impl AccountInterface {
pub fn new(imp: impl AccountImpl + 'static, cnx: zbus::Connection) -> Self {
Self {
imp: Arc::new(Box::new(imp)),
imp: Arc::new(imp),
cnx,
}
}
Expand All @@ -67,16 +67,16 @@ impl AccountInterface {
let window_identifier = WindowIdentifierType::from_maybe_str(window_identifier);
let app_id = AppID::from_maybe_str(app_id);

let imp: Arc<Box<dyn AccountImpl>> = Arc::clone(&self.imp);
let imp = Arc::clone(&self.imp);
let (fut, request_handle) = abortable(async {
imp.get_user_information(app_id, window_identifier, options)
.await
});

let imp_request = Arc::clone(&self.imp);
let imp = Arc::clone(&self.imp);
let close_cb = || {
tokio::spawn(async move {
RequestImpl::close(&**imp_request).await;
RequestImpl::close(&*imp).await;
});
};
let request = Request::new(close_cb, handle.clone(), request_handle, self.cnx.clone());
Expand Down
16 changes: 8 additions & 8 deletions src/backend/screenshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ pub trait ScreenshotImpl: RequestImpl {
}

pub struct ScreenshotInterface {
imp: Arc<Box<dyn ScreenshotImpl>>,
imp: Arc<dyn ScreenshotImpl>,
cnx: zbus::Connection,
}

impl ScreenshotInterface {
pub fn new(imp: impl ScreenshotImpl + 'static, cnx: zbus::Connection) -> Self {
Self {
imp: Arc::new(Box::new(imp)),
imp: Arc::new(imp),
cnx,
}
}
Expand Down Expand Up @@ -89,14 +89,14 @@ impl ScreenshotInterface {
let window_identifier = WindowIdentifierType::from_maybe_str(window_identifier);
let app_id = AppID::from_maybe_str(app_id);

let imp: Arc<Box<dyn ScreenshotImpl>> = Arc::clone(&self.imp);
let imp = Arc::clone(&self.imp);
let (fut, request_handle) =
abortable(async { imp.screenshot(app_id, window_identifier, options).await });

let imp_request = Arc::clone(&self.imp);
let imp = Arc::clone(&self.imp);
let close_cb = || {
tokio::spawn(async move {
RequestImpl::close(&**imp_request).await;
RequestImpl::close(&*imp).await;
});
};
let request = Request::new(close_cb, handle.clone(), request_handle, self.cnx.clone());
Expand Down Expand Up @@ -126,14 +126,14 @@ impl ScreenshotInterface {
let window_identifier = WindowIdentifierType::from_maybe_str(window_identifier);
let app_id = AppID::from_maybe_str(app_id);

let imp: Arc<Box<dyn ScreenshotImpl>> = Arc::clone(&self.imp);
let imp = Arc::clone(&self.imp);
let (fut, request_handle) =
abortable(async { imp.pick_color(app_id, window_identifier, options).await });

let imp_request = Arc::clone(&self.imp);
let imp = Arc::clone(&self.imp);
let close_cb = || {
tokio::spawn(async move {
RequestImpl::close(&**imp_request).await;
RequestImpl::close(&*imp).await;
});
};
let request = Request::new(close_cb, handle.clone(), request_handle, self.cnx.clone());
Expand Down
10 changes: 5 additions & 5 deletions src/backend/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ pub trait SecretImpl: RequestImpl {
}

pub struct SecretInterface {
imp: Arc<Box<dyn SecretImpl>>,
imp: Arc<dyn SecretImpl>,
cnx: zbus::Connection,
}

impl SecretInterface {
pub fn new(imp: impl SecretImpl + 'static, cnx: zbus::Connection) -> Self {
Self {
imp: Arc::new(Box::new(imp)),
imp: Arc::new(imp),
cnx,
}
}
Expand All @@ -52,13 +52,13 @@ impl SecretInterface {
#[cfg(feature = "tracing")]
tracing::debug!("Secret::RetrieveSecret");

let imp: Arc<Box<dyn SecretImpl>> = Arc::clone(&self.imp);
let imp = Arc::clone(&self.imp);
let (fut, request_handle) = abortable(async { imp.retrieve(app_id, fd).await });

let imp_request = Arc::clone(&self.imp);
let imp = Arc::clone(&self.imp);
let close_cb = || {
tokio::spawn(async move {
RequestImpl::close(&**imp_request).await;
RequestImpl::close(&*imp).await;
});
};
let request = Request::new(close_cb, handle.clone(), request_handle, self.cnx.clone());
Expand Down
4 changes: 2 additions & 2 deletions src/backend/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ pub trait SettingsImpl: Send + Sync {
}

pub struct SettingsInterface {
imp: Arc<Box<dyn SettingsImpl>>,
imp: Arc<dyn SettingsImpl>,
cnx: zbus::Connection,
}

impl SettingsInterface {
pub fn new(imp: impl SettingsImpl + 'static, cnx: zbus::Connection) -> Self {
Self {
imp: Arc::new(Box::new(imp)),
imp: Arc::new(imp),
cnx,
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/backend/wallpaper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ pub trait WallpaperImpl: RequestImpl {
}

pub struct WallpaperInterface {
imp: Arc<Box<dyn WallpaperImpl>>,
imp: Arc<dyn WallpaperImpl>,
cnx: zbus::Connection,
}

impl WallpaperInterface {
pub fn new(imp: impl WallpaperImpl + 'static, cnx: zbus::Connection) -> Self {
Self {
imp: Arc::new(Box::new(imp)),
imp: Arc::new(imp),
cnx,
}
}
Expand Down Expand Up @@ -79,14 +79,14 @@ impl WallpaperInterface {
let window_identifier = WindowIdentifierType::from_maybe_str(window_identifier);
let app_id = AppID::from_maybe_str(app_id);

let imp: Arc<Box<dyn WallpaperImpl>> = Arc::clone(&self.imp);
let imp = Arc::clone(&self.imp);
let (fut, request_handle) =
abortable(async { imp.with_uri(app_id, window_identifier, uri, options).await });

let imp_request = Arc::clone(&self.imp);
let imp = Arc::clone(&self.imp);
let close_cb = || {
tokio::spawn(async move {
RequestImpl::close(&**imp_request).await;
RequestImpl::close(&*imp).await;
});
};
let request = Request::new(close_cb, handle.clone(), request_handle, self.cnx.clone());
Expand Down

0 comments on commit 6e05363

Please sign in to comment.