Skip to content

Commit 5aa1cb1

Browse files
docs: Don't duplicate attributes
1 parent 96c5485 commit 5aa1cb1

File tree

4 files changed

+13
-34
lines changed

4 files changed

+13
-34
lines changed

README.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,17 @@ use std::collections::HashMap;
3232
3333
async fn run() -> oo7::Result<()> {
3434
let keyring = oo7::Keyring::new().await?;
35+
let attributes = HashMap::from([("attribute", "attribute_value")]);
3536
3637
// Store a secret
37-
keyring.create_item(
38-
"Item Label",
39-
&HashMap::from([("attribute", "attribute_value")]),
40-
b"secret",
41-
true,
42-
).await?;
38+
keyring
39+
.create_item("Item Label", &attributes, b"secret", true).await?;
4340
4441
// Find a stored secret
45-
let items = keyring
46-
.search_items(&HashMap::from([("attribute", "attribute_value")]))
47-
.await?;
42+
let items = keyring.search_items(&attributes).await?;
4843
4944
// Delete a stored secret
50-
keyring
51-
.delete(&HashMap::from([("attribute", "attribute_value")]))
52-
.await?;
45+
keyring.delete(&attributes).await?;
5346
5447
// Unlock the collection if the Secret Service is used
5548
keyring.unlock().await?;

client/examples/basic.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@ use oo7::Keyring;
55
#[tokio::main]
66
async fn main() -> oo7::Result<()> {
77
let keyring = Keyring::new().await?;
8+
let attributes = HashMap::from([("attr", "value")]);
89
keyring
9-
.create_item(
10-
"Some Label",
11-
&HashMap::from([("attr", "value")]),
12-
b"secret",
13-
true,
14-
)
10+
.create_item("Some Label", &attributes, b"secret", true)
1511
.await?;
1612

17-
let items = keyring
18-
.search_items(&HashMap::from([("attr", "value")]))
19-
.await?;
13+
let items = keyring.search_items(&attributes).await?;
2014

2115
for item in items {
2216
println!("{}", item.label().await?);

client/examples/basic_2.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,15 @@ async fn main() -> oo7::Result<()> {
99
let keyring = Keyring::new().await?;
1010
KEYRING.set(keyring).unwrap();
1111

12+
let attributes = HashMap::from([("attr", "value")]);
13+
1214
KEYRING
1315
.get()
1416
.unwrap()
15-
.create_item(
16-
"Some Label",
17-
&HashMap::from([("attr", "value")]),
18-
b"secret",
19-
true,
20-
)
17+
.create_item("Some Label", &attributes, b"secret", true)
2118
.await?;
2219

23-
let items = KEYRING
24-
.get()
25-
.unwrap()
26-
.search_items(&HashMap::from([("attr", "value")]))
27-
.await?;
20+
let items = KEYRING.get().unwrap().search_items(&attributes).await?;
2821

2922
for item in items {
3023
println!("{}", item.label().await?);

client/examples/dbus_service.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use oo7::dbus::Service;
66
async fn main() -> oo7::Result<()> {
77
let service = Service::new().await?;
88

9-
let mut attributes = HashMap::new();
10-
attributes.insert("type", "token");
9+
let attributes = HashMap::from([("type", "token")]);
1110
let collection = service.default_collection().await?;
1211
let items = collection.search_items(&attributes).await?;
1312
for item in items {

0 commit comments

Comments
 (0)