Skip to content

Commit

Permalink
portal: update create_item() to return portal::Item
Browse files Browse the repository at this point in the history
This change updates the oo7::portal::Keyring::create_item() to return
oo7::portal::Item instead of ()

We need this change for the server side implementation. In server/daemon
side we are wrapping the return value of create_item() inside a struct.

Signed-off-by: Dhanuka Warusadura <dhanuka@gnome.org>
  • Loading branch information
warusadura committed Feb 9, 2024
1 parent a0d4dc7 commit 355c9a1
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions client/src/portal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,21 @@ impl Keyring {
attributes: HashMap<&str, &str>,
secret: impl AsRef<[u8]>,
replace: bool,
) -> Result<(), Error> {
{
let mut opt_key = self.key.write().await;
let key = self.derive_key(&mut opt_key).await;
let mut keyring = self.keyring.write().await;
if replace {
keyring.remove_items(&attributes, key)?;
}
let item = Item::new(label, attributes, secret);
let encrypted_item = item.encrypt(key)?;
keyring.items.push(encrypted_item);
};
self.write().await
) -> Result<Item, Error> {
let mut opt_key = self.key.write().await;
let key = self.derive_key(&mut opt_key).await;
let mut keyring = self.keyring.write().await;
if replace {
keyring.remove_items(&attributes, key)?;
}
let item = Item::new(label, attributes, secret);
let encrypted_item = item.encrypt(key)?;
keyring.items.push(encrypted_item);

match self.write().await {
Err(e) => Err(e),
Ok(_) => Ok(item),
}
}

/// Replaces item at the given index.
Expand Down

0 comments on commit 355c9a1

Please sign in to comment.