Skip to content

Commit

Permalink
clean code for PR
Browse files Browse the repository at this point in the history
  • Loading branch information
soywod committed Oct 11, 2024
1 parent e2f54a1 commit 80dd557
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ exclude = [".github/"]
readme = "README.md"

[features]
default = []
linux-native = ["dep:linux-keyutils"]
apple-native = ["dep:security-framework"]
windows-native = ["dep:windows-sys", "dep:byteorder"]
Expand Down
33 changes: 26 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ pub mod mock;
//

#[cfg(all(
not(doc),
any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"),
all(feature = "sync-secret-service", feature = "async-secret-service"),
all(feature = "sync-secret-service", feature = "async-secret-service")
))]
compile_error!("You can enable at most one secret service keystore");

Expand All @@ -182,28 +183,36 @@ pub mod keyutils;
#[cfg(all(
target_os = "linux",
feature = "linux-native",
not(any(feature = "sync-secret-service", feature = "async-secret-service")),
not(all(
doc,
any(feature = "sync-secret-service", feature = "async-secret-service")
))
))]
pub use keyutils as default;

#[cfg(all(
any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"),
any(feature = "sync-secret-service", feature = "async-secret-service"),
any(feature = "sync-secret-service", feature = "async-secret-service")
))]
pub mod secret_service;
#[cfg(all(
any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"),
any(feature = "sync-secret-service", feature = "async-secret-service"),
any(feature = "sync-secret-service", feature = "async-secret-service")
))]
pub use secret_service as default;

#[cfg(all(
any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"),
target_os = "linux",
not(any(
feature = "linux-native",
feature = "sync-secret-service",
feature = "async-secret-service",
)),
feature = "async-secret-service"
))
))]
pub use mock as default;
#[cfg(all(
any(target_os = "freebsd", target_os = "openbsd"),
not(any(feature = "sync-secret-service", feature = "async-secret-service"))
))]
pub use mock as default;

Expand Down Expand Up @@ -236,6 +245,16 @@ pub use mock as default;
#[cfg(all(target_os = "windows", feature = "windows-native"))]
pub use windows as default;

#[cfg(not(any(
target_os = "linux",
target_os = "freebsd",
target_os = "openbsd",
target_os = "macos",
target_os = "ios",
target_os = "windows",
)))]
pub use mock as default;

pub mod credential;
pub mod error;

Expand Down
6 changes: 3 additions & 3 deletions src/secret_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ issue for more details and possible workarounds.
*/
use std::collections::HashMap;

#[cfg(feature = "sync-secret-service")]
#[cfg(not(feature = "async-secret-service"))]
use dbus_secret_service::{Collection, EncryptionType, Error, Item, SecretService};
#[cfg(feature = "async-secret-service")]
use secret_service::{
Expand Down Expand Up @@ -844,7 +844,7 @@ mod tests {
}

fn delete_collection(name: &str) {
#[cfg(feature = "sync-secret-service")]
#[cfg(not(feature = "async-secret-service"))]
use dbus_secret_service::{EncryptionType, SecretService};
#[cfg(feature = "async-secret-service")]
use secret_service::{blocking::SecretService, EncryptionType};
Expand All @@ -856,7 +856,7 @@ mod tests {
}

fn create_v1_entry(name: &str, password: &str) {
#[cfg(feature = "sync-secret-service")]
#[cfg(not(feature = "async-secret-service"))]
use dbus_secret_service::{EncryptionType, SecretService};
#[cfg(feature = "async-secret-service")]
use secret_service::{blocking::SecretService, EncryptionType};
Expand Down

0 comments on commit 80dd557

Please sign in to comment.