Skip to content

Commit 762ff80

Browse files
nikarhcomplexspaces
authored andcommitted
Added unlock_all method
1 parent 3e8e7c5 commit 762ff80

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/blocking/mod.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
//! [zbus's blocking documentation]: https://docs.rs/zbus/latest/zbus/blocking/index.html
1818
//! [async `SecretService`]: crate::SecretService
1919
20-
use crate::proxy::service::ServiceProxyBlocking;
2120
use crate::session::Session;
2221
use crate::ss::SS_COLLECTION_LABEL;
2322
use crate::util;
23+
use crate::{proxy::service::ServiceProxyBlocking, util::exec_prompt_blocking};
2424
use crate::{EncryptionType, Error, SearchItemsResult};
2525
use std::collections::HashMap;
2626
use zbus::zvariant::{ObjectPath, Value};
@@ -178,6 +178,18 @@ impl<'a> SecretService<'a> {
178178
locked: object_paths_to_items(items.locked)?,
179179
})
180180
}
181+
182+
/// Unlock all items in a batch
183+
pub fn unlock_all(&self, items: &[&Item<'_>]) -> Result<(), Error> {
184+
let objects = items.iter().map(|i| &*i.item_path).collect();
185+
let lock_action_res = self.service_proxy.unlock(objects)?;
186+
187+
if lock_action_res.object_paths.is_empty() {
188+
exec_prompt_blocking(self.conn.clone(), &lock_action_res.prompt)?;
189+
}
190+
191+
Ok(())
192+
}
181193
}
182194

183195
#[cfg(test)]

src/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,18 @@ impl<'a> SecretService<'a> {
326326
.collect::<Result<_, _>>()?,
327327
})
328328
}
329+
330+
/// Unlock all items in a batch
331+
pub async fn unlock_all(&self, items: &[&Item<'_>]) -> Result<(), Error> {
332+
let objects = items.iter().map(|i| &*i.item_path).collect();
333+
let lock_action_res = self.service_proxy.unlock(objects).await?;
334+
335+
if lock_action_res.object_paths.is_empty() {
336+
exec_prompt(self.conn.clone(), &lock_action_res.prompt).await?;
337+
}
338+
339+
Ok(())
340+
}
329341
}
330342

331343
#[cfg(test)]

0 commit comments

Comments
 (0)