Skip to content

Commit a4dbe25

Browse files
committed
Update to use keyring-core 0.7.
Takes advantage of the boolean option type. Fixes open-source-cooperative/linux-utils-keyring-store#3.
1 parent f0c6a20 commit a4dbe25

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ edition = "2024"
1616
name = "example"
1717

1818
[dependencies]
19-
keyring-core = { version = "0.6" }
19+
keyring-core = { version = "0.7" }
2020
linux-keyutils = { version = "0.2.4", features = ["std"] }
2121

2222
[dev-dependencies]

src/store.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ use std::fmt::Formatter;
33
use std::sync::Arc;
44
use std::time::{SystemTime, UNIX_EPOCH};
55

6-
use keyring_core::Entry;
76
use keyring_core::api::{CredentialPersistence, CredentialStoreApi};
87
use keyring_core::attributes::parse_attributes;
9-
use keyring_core::error::{Error, Result};
8+
use keyring_core::{Entry, Result};
109

1110
use super::Cred;
1211

@@ -38,7 +37,7 @@ impl Store {
3837
/// the config option `service_no_divider` to `true`.
3938
pub fn new_with_configuration(config: &HashMap<&str, &str>) -> Result<Arc<Self>> {
4039
let config = parse_attributes(
41-
&["prefix", "divider", "suffix", "service_no_divider"],
40+
&["prefix", "divider", "suffix", "*service_no_divider"],
4241
Some(config),
4342
)?;
4443
let prefix = config
@@ -56,17 +55,11 @@ impl Store {
5655
.map(|s| s.as_str())
5756
.unwrap_or("")
5857
.to_string();
59-
let service_no_divider = match config.get("service_no_divider").map(|s| s.as_str()) {
60-
None => false,
61-
Some("true") => true,
62-
Some("false") => false,
63-
Some(_) => {
64-
return Err(Error::Invalid(
65-
"service_no_divider".to_string(),
66-
"must be true or false".to_string(),
67-
));
68-
}
69-
};
58+
let service_no_divider = config
59+
.get("service_no_divider")
60+
.map(|s| s.as_str())
61+
.unwrap_or("false")
62+
.eq("true");
7063
Ok(Self::new_internal(
7164
[prefix, divider, suffix],
7265
service_no_divider,

0 commit comments

Comments
 (0)