Skip to content

Commit

Permalink
Update zbus to v4
Browse files Browse the repository at this point in the history
  • Loading branch information
liff authored and complexspaces committed Jun 8, 2024
1 parent 898edd9 commit 7d7c75e
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 39 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:

- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: "1.64.0"
toolchain: "1.75.0"
components: clippy

- uses: actions/cache@v4
Expand All @@ -129,11 +129,8 @@ jobs:
key: $clippy-cache-${{ steps.toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}

- name: Generate lockfile
# XXX: Downgrade various dependencies to make them or their sub-dependencies MSRV compatible.
run: |
cargo generate-lockfile
cargo update -p proc-macro-crate --precise "1.3.0"
cargo update -p regex --precise "1.9.6"
- name: Clippy MSRV
run: cargo clippy --features=rt-tokio-crypto-rust --all-targets --all -- -D clippy::dbg_macro -D warnings -F unused_must_use
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "secret-service"
repository = "https://github.com/hwchen/secret-service-rs.git"
edition = "2021"
version = "3.1.0"
rust-version = "1.64.0"
rust-version = "1.75.0"

# The async runtime features mirror those of `zbus` for compatibility.
[features]
Expand All @@ -33,7 +33,7 @@ num = "0.4.0"
rand = "0.8.1"
serde = { version = "1.0.103", features = ["derive"] }
sha2 = { version = "0.10.0", optional = true }
zbus = { version = "3.7", default-features = false }
zbus = { version = "4", default-features = false }
openssl = { version = "^0.10.40", optional = true }

[dev-dependencies]
Expand Down
19 changes: 8 additions & 11 deletions src/proxy/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use zbus::{
dbus_proxy,
zvariant::{ObjectPath, OwnedObjectPath, Type, Value},
};
use zbus::zvariant::{ObjectPath, OwnedObjectPath, Type, Value};

use super::SecretStruct;

Expand All @@ -21,7 +18,7 @@ use super::SecretStruct;
/// This will derive CollectionProxy
///
/// Note that `Value` in the method signatures corresponds to `VARIANT` dbus type.
#[dbus_proxy(
#[zbus::proxy(
interface = "org.freedesktop.Secret.Collection",
default_service = "org.freedesktop.Secret.Collection"
)]
Expand All @@ -38,22 +35,22 @@ trait Collection {
replace: bool,
) -> zbus::Result<CreateItemResult>;

#[dbus_proxy(property)]
#[zbus(property)]
fn items(&self) -> zbus::fdo::Result<Vec<ObjectPath<'_>>>;

#[dbus_proxy(property)]
#[zbus(property)]
fn label(&self) -> zbus::fdo::Result<String>;

#[dbus_proxy(property)]
#[zbus(property)]
fn set_label(&self, new_label: &str) -> zbus::fdo::Result<()>;

#[dbus_proxy(property)]
#[zbus(property)]
fn locked(&self) -> zbus::fdo::Result<bool>;

#[dbus_proxy(property)]
#[zbus(property)]
fn created(&self) -> zbus::fdo::Result<u64>;

#[dbus_proxy(property)]
#[zbus(property)]
fn modified(&self) -> zbus::fdo::Result<u64>;
}

Expand Down
21 changes: 9 additions & 12 deletions src/proxy/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@
//! A dbus proxy for speaking with secret service's `Item` Interface.
use std::collections::HashMap;
use zbus::{
dbus_proxy,
zvariant::{ObjectPath, OwnedObjectPath},
};
use zbus::zvariant::{ObjectPath, OwnedObjectPath};

use super::SecretStruct;

/// A dbus proxy for speaking with secret service's `Item` Interface.
///
/// This will derive ItemProxy
#[dbus_proxy(
#[zbus::proxy(
interface = "org.freedesktop.Secret.Item",
default_service = "org.freedesktop.Secret.Item"
)]
Expand All @@ -30,24 +27,24 @@ trait Item {

fn set_secret(&self, secret: SecretStruct) -> zbus::Result<()>;

#[dbus_proxy(property)]
#[zbus(property)]
fn locked(&self) -> zbus::fdo::Result<bool>;

#[dbus_proxy(property)]
#[zbus(property)]
fn attributes(&self) -> zbus::fdo::Result<HashMap<String, String>>;

#[dbus_proxy(property)]
#[zbus(property)]
fn set_attributes(&self, attributes: HashMap<&str, &str>) -> zbus::fdo::Result<()>;

#[dbus_proxy(property)]
#[zbus(property)]
fn label(&self) -> zbus::fdo::Result<String>;

#[dbus_proxy(property)]
#[zbus(property)]
fn set_label(&self, new_label: &str) -> zbus::fdo::Result<()>;

#[dbus_proxy(property)]
#[zbus(property)]
fn created(&self) -> zbus::fdo::Result<u64>;

#[dbus_proxy(property)]
#[zbus(property)]
fn modified(&self) -> zbus::fdo::Result<u64>;
}
6 changes: 3 additions & 3 deletions src/proxy/prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

//! A dbus proxy for speaking with secret service's `Prompt` Interface.
use zbus::{dbus_proxy, zvariant::Value};
use zbus::zvariant::Value;

/// A dbus proxy for speaking with secret service's `Prompt` Interface.
///
/// This will derive PromptProxy
///
/// Note that `Value` in the method signatures corresponds to `VARIANT` dbus type.
#[dbus_proxy(
#[zbus::proxy(
interface = "org.freedesktop.Secret.Prompt",
default_service = "org.freedesktop.Secret.Prompt"
)]
Expand All @@ -23,6 +23,6 @@ trait Prompt {

fn dismiss(&self) -> zbus::Result<()>;

#[dbus_proxy(signal)]
#[zbus(signal)]
fn completed(&self, dismissed: bool, result: Value<'_>) -> zbus::Result<()>;
}
9 changes: 3 additions & 6 deletions src/proxy/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@
use super::SecretStruct;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use zbus::{
dbus_proxy,
zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value},
};
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value};

/// A dbus proxy for speaking with secret service's `Service` Interface.
///
/// This will derive ServiceProxy
///
/// Note that `Value` in the method signatures corresponds to `VARIANT` dbus type.
#[dbus_proxy(
#[zbus::proxy(
interface = "org.freedesktop.Secret.Service",
default_service = "org.freedesktop.secrets",
default_path = "/org/freedesktop/secrets"
Expand Down Expand Up @@ -49,7 +46,7 @@ trait Service {

fn set_alias(&self, name: &str, collection: ObjectPath<'_>) -> zbus::Result<()>;

#[dbus_proxy(property)]
#[zbus(property)]
fn collections(&self) -> zbus::fdo::Result<Vec<ObjectPath<'_>>>;
}

Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ fn handle_signal(signal: Completed) -> Result<zvariant::OwnedValue, Error> {
if args.dismissed {
Err(Error::Prompt)
} else {
Ok(args.result.into())
zvariant::OwnedValue::try_from(args.result).map_err(From::from)
}
}

Expand Down

0 comments on commit 7d7c75e

Please sign in to comment.