Skip to content

Commit

Permalink
backend: Remove useless version consts
Browse files Browse the repository at this point in the history
As it is hardcoded in the implemented interfaces already
  • Loading branch information
bilelmoussaoui committed Aug 10, 2024
1 parent 0fef5ca commit e619487
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 48 deletions.
12 changes: 4 additions & 8 deletions src/backend/access.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, num::NonZeroU32, sync::Arc};
use std::{collections::HashMap, sync::Arc};

use async_trait::async_trait;
use futures_channel::{
Expand All @@ -23,8 +23,6 @@ use crate::{

#[async_trait]
pub trait AccessImpl {
const VERSION: NonZeroU32;

async fn access_dialog(
&self,
app_id: AppID,
Expand All @@ -45,7 +43,7 @@ pub struct Access<T: AccessImpl + RequestImpl> {
impl<T: AccessImpl + RequestImpl> Access<T> {
pub async fn new(imp: T, backend: &Backend) -> zbus::Result<Self> {
let (sender, receiver) = futures_channel::mpsc::unbounded();
let iface = AccessInterface::new(sender, T::VERSION);
let iface = AccessInterface::new(sender);
backend.serve(iface).await?;
let provider = Self {
receiver: Arc::new(Mutex::new(receiver)),
Expand Down Expand Up @@ -114,14 +112,12 @@ enum Action {

struct AccessInterface {
sender: Arc<Mutex<Sender<Action>>>,
version: NonZeroU32,
}

impl AccessInterface {
pub fn new(sender: Sender<Action>, version: NonZeroU32) -> Self {
pub fn new(sender: Sender<Action>) -> Self {
Self {
sender: Arc::new(Mutex::new(sender)),
version,
}
}
}
Expand All @@ -130,7 +126,7 @@ impl AccessInterface {
impl AccessInterface {
#[dbus_interface(property, name = "version")]
fn version(&self) -> u32 {
self.version.into()
1 // TODO: Is this correct?
}

#[allow(clippy::too_many_arguments)]
Expand Down
12 changes: 4 additions & 8 deletions src/backend/account.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{num::NonZeroU32, sync::Arc};
use std::sync::Arc;

use async_trait::async_trait;
use futures_channel::{
Expand Down Expand Up @@ -35,8 +35,6 @@ impl UserInformationOptions {

#[async_trait]
pub trait AccountImpl: RequestImpl {
const VERSION: NonZeroU32;

async fn get_information(
&self,
app_id: AppID,
Expand All @@ -54,7 +52,7 @@ pub struct Account<T: AccountImpl + RequestImpl> {
impl<T: AccountImpl + RequestImpl> Account<T> {
pub async fn new(imp: T, backend: &Backend) -> zbus::Result<Self> {
let (sender, receiver) = futures_channel::mpsc::unbounded();
let iface = AccountInterface::new(sender, T::VERSION);
let iface = AccountInterface::new(sender);
backend.serve(iface).await?;
let provider = Self {
receiver: Arc::new(Mutex::new(receiver)),
Expand Down Expand Up @@ -112,14 +110,12 @@ enum Action {

struct AccountInterface {
sender: Arc<Mutex<Sender<Action>>>,
version: NonZeroU32,
}

impl AccountInterface {
pub fn new(sender: Sender<Action>, version: NonZeroU32) -> Self {
pub fn new(sender: Sender<Action>) -> Self {
Self {
sender: Arc::new(Mutex::new(sender)),
version,
}
}
}
Expand All @@ -128,7 +124,7 @@ impl AccountInterface {
impl AccountInterface {
#[zbus(property, name = "version")]
fn version(&self) -> u32 {
self.version.into()
1
}

#[zbus(name = "GetUserInformation")]
Expand Down
12 changes: 4 additions & 8 deletions src/backend/screenshot.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{num::NonZeroU32, sync::Arc};
use std::sync::Arc;

use async_trait::async_trait;
use futures_channel::{
Expand Down Expand Up @@ -49,8 +49,6 @@ pub struct ColorOptions;

#[async_trait]
pub trait ScreenshotImpl {
const VERSION: NonZeroU32;

async fn screenshot(
&self,
app_id: AppID,
Expand All @@ -75,7 +73,7 @@ pub struct Screenshot<T: ScreenshotImpl + RequestImpl> {
impl<T: ScreenshotImpl + RequestImpl> Screenshot<T> {
pub async fn new(imp: T, backend: &Backend) -> zbus::Result<Self> {
let (sender, receiver) = futures_channel::mpsc::unbounded();
let iface = ScreenshotInterface::new(sender, T::VERSION);
let iface = ScreenshotInterface::new(sender);
backend.serve(iface).await?;
let provider = Self {
receiver: Arc::new(Mutex::new(receiver)),
Expand Down Expand Up @@ -169,14 +167,12 @@ enum Action {

struct ScreenshotInterface {
sender: Arc<Mutex<Sender<Action>>>,
version: NonZeroU32,
}

impl ScreenshotInterface {
pub fn new(sender: Sender<Action>, version: NonZeroU32) -> Self {
pub fn new(sender: Sender<Action>) -> Self {
Self {
sender: Arc::new(Mutex::new(sender)),
version,
}
}
}
Expand All @@ -185,7 +181,7 @@ impl ScreenshotInterface {
impl ScreenshotInterface {
#[zbus(property, name = "version")]
fn version(&self) -> u32 {
self.version.into()
2
}

#[zbus(name = "Screenshot")]
Expand Down
12 changes: 4 additions & 8 deletions src/backend/secret.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, num::NonZeroU32, sync::Arc};
use std::{collections::HashMap, sync::Arc};

use async_trait::async_trait;
use futures_channel::{
Expand All @@ -23,8 +23,6 @@ use crate::{

#[async_trait]
pub trait SecretImpl {
const VERSION: NonZeroU32;

async fn retrieve(
&self,
app_id: AppID,
Expand All @@ -51,7 +49,7 @@ pub struct Secret<T: SecretImpl + RequestImpl> {
impl<T: SecretImpl + RequestImpl> Secret<T> {
pub async fn new(imp: T, backend: &Backend) -> zbus::Result<Self> {
let (sender, receiver) = futures_channel::mpsc::unbounded();
let iface = SecretInterface::new(sender, T::VERSION);
let iface = SecretInterface::new(sender);
backend.serve(iface).await?;
let provider = Self {
receiver: Arc::new(Mutex::new(receiver)),
Expand Down Expand Up @@ -96,22 +94,20 @@ impl<T: SecretImpl + RequestImpl> Secret<T> {

struct SecretInterface {
sender: Arc<Mutex<Sender<Action>>>,
version: NonZeroU32,
}

impl SecretInterface {
pub fn new(sender: Sender<Action>, version: NonZeroU32) -> Self {
pub fn new(sender: Sender<Action>) -> Self {
Self {
sender: Arc::new(Mutex::new(sender)),
version,
}
}
}
#[zbus::interface(name = "org.freedesktop.impl.portal.Secret")]
impl SecretInterface {
#[dbus_interface(property, name = "version")]
fn version(&self) -> u32 {
self.version.into()
1
}

#[dbus_interface(out_args("response", "results"))]
Expand Down
12 changes: 4 additions & 8 deletions src/backend/settings.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, num::NonZeroU32, sync::Arc};
use std::{collections::HashMap, sync::Arc};

use async_trait::async_trait;
use futures_channel::{
Expand All @@ -12,8 +12,6 @@ use crate::{backend::Backend, desktop::settings::Namespace, zvariant::OwnedValue

#[async_trait]
pub trait SettingsImpl {
const VERSION: NonZeroU32;

async fn read_all(&self, namespaces: Vec<String>) -> HashMap<String, Namespace>;

async fn read(&self, namespace: &str, key: &str) -> OwnedValue;
Expand All @@ -27,7 +25,7 @@ pub struct Settings<T: SettingsImpl> {
impl<T: SettingsImpl> Settings<T> {
pub async fn new(imp: T, backend: &Backend) -> zbus::Result<Self> {
let (sender, receiver) = futures_channel::mpsc::channel(10);
let iface = SettingsInterface::new(sender, T::VERSION);
let iface = SettingsInterface::new(sender);
backend.serve(iface).await?;
let provider = Self {
receiver: Arc::new(Mutex::new(receiver)),
Expand Down Expand Up @@ -67,14 +65,12 @@ enum Action {

struct SettingsInterface {
sender: Arc<Mutex<Sender<Action>>>,
version: NonZeroU32,
}

impl SettingsInterface {
pub fn new(sender: Sender<Action>, version: NonZeroU32) -> Self {
pub fn new(sender: Sender<Action>) -> Self {
Self {
sender: Arc::new(Mutex::new(sender)),
version,
}
}
}
Expand All @@ -83,7 +79,7 @@ impl SettingsInterface {
impl SettingsInterface {
#[zbus(property, name = "version")]
fn version(&self) -> u32 {
self.version.into()
2
}

async fn read_all(&self, namespaces: Vec<String>) -> HashMap<String, Namespace> {
Expand Down
12 changes: 4 additions & 8 deletions src/backend/wallpaper.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{num::NonZeroU32, sync::Arc};
use std::sync::Arc;

use async_trait::async_trait;
use futures_channel::{
Expand Down Expand Up @@ -45,8 +45,6 @@ impl WallpaperOptions {

#[async_trait]
pub trait WallpaperImpl {
const VERSION: NonZeroU32;

async fn with_uri(
&self,
app_id: AppID,
Expand All @@ -65,7 +63,7 @@ pub struct Wallpaper<T: WallpaperImpl + RequestImpl> {
impl<T: WallpaperImpl + RequestImpl> Wallpaper<T> {
pub async fn new(imp: T, backend: &Backend) -> zbus::Result<Self> {
let (sender, receiver) = futures_channel::mpsc::unbounded();
let iface = WallpaperInterface::new(sender, T::VERSION);
let iface = WallpaperInterface::new(sender);
backend.serve(iface).await?;
let provider = Self {
receiver: Arc::new(Mutex::new(receiver)),
Expand Down Expand Up @@ -122,14 +120,12 @@ enum Action {

struct WallpaperInterface {
sender: Arc<Mutex<Sender<Action>>>,
version: NonZeroU32,
}

impl WallpaperInterface {
pub fn new(sender: Sender<Action>, version: NonZeroU32) -> Self {
pub fn new(sender: Sender<Action>) -> Self {
Self {
sender: Arc::new(Mutex::new(sender)),
version,
}
}
}
Expand All @@ -138,7 +134,7 @@ impl WallpaperInterface {
impl WallpaperInterface {
#[zbus(property, name = "version")]
fn version(&self) -> u32 {
self.version.into()
1
}

#[zbus(name = "SetWallpaperURI")]
Expand Down

0 comments on commit e619487

Please sign in to comment.