secret_service/proxy/
collection.rs

1//! A dbus proxy for speaking with secret service's `Collection` Interface.
2
3use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5use zbus::zvariant::{ObjectPath, OwnedObjectPath, Type, Value};
6
7use super::SecretStruct;
8
9/// A dbus proxy for speaking with secret service's `Collection` Interface.
10///
11/// This will derive CollectionProxy
12///
13/// Note that `Value` in the method signatures corresponds to `VARIANT` dbus type.
14#[zbus::proxy(
15    interface = "org.freedesktop.Secret.Collection",
16    default_service = "org.freedesktop.Secret.Collection"
17)]
18pub trait Collection {
19    /// Returns prompt: ObjectPath
20    fn delete(&self) -> zbus::Result<OwnedObjectPath>;
21
22    fn search_items(&self, attributes: HashMap<&str, &str>) -> zbus::Result<Vec<OwnedObjectPath>>;
23
24    fn create_item(
25        &self,
26        properties: HashMap<&str, Value<'_>>,
27        secret: SecretStruct,
28        replace: bool,
29    ) -> zbus::Result<CreateItemResult>;
30
31    #[zbus(property)]
32    fn items(&self) -> zbus::fdo::Result<Vec<ObjectPath<'_>>>;
33
34    #[zbus(property)]
35    fn label(&self) -> zbus::fdo::Result<String>;
36
37    #[zbus(property)]
38    fn set_label(&self, new_label: &str) -> zbus::fdo::Result<()>;
39
40    #[zbus(property)]
41    fn locked(&self) -> zbus::fdo::Result<bool>;
42
43    #[zbus(property)]
44    fn created(&self) -> zbus::fdo::Result<u64>;
45
46    #[zbus(property)]
47    fn modified(&self) -> zbus::fdo::Result<u64>;
48}
49
50#[derive(Debug, Serialize, Deserialize, Type)]
51pub struct CreateItemResult {
52    pub(crate) item: OwnedObjectPath,
53    pub(crate) prompt: OwnedObjectPath,
54}