1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::collections::HashMap;

use crate::Retrievable;
use glib::object::IsA;
use glib::translate::*;

pub trait RetrievableExtManual: 'static {
    /// Get the attributes of this object.
    ///
    /// The attributes are a mapping of string keys to string values.
    /// Attributes are used to search for items. Attributes are not stored
    /// or transferred securely by the secret service.
    ///
    /// Do not modify the attribute returned by this method.
    ///
    /// # Returns
    ///
    /// a new reference
    ///   to the attributes, which should not be modified, and
    ///   released with `GLib::HashTable::unref()`
    #[doc(alias = "secret_retrievable_get_attributes")]
    #[doc(alias = "get_attributes")]
    fn attributes(&self) -> HashMap<String, String>;
}

impl<O: IsA<Retrievable>> RetrievableExtManual for O {
    fn attributes(&self) -> HashMap<String, String> {
        unsafe {
            let table = ffi::secret_retrievable_get_attributes(self.as_ref().to_glib_none().0);
            FromGlibPtrContainer::from_glib_full(table)
        }
    }
}