Struct secret::SecretService
[−]
[src]
pub struct SecretService(_);
A SecretService object represents the Secret Service implementation which
runs as a D-Bus service.
In order to securely transfer secrets to the Sercret Service, a session is
established. This will automatically be done when calling
SecretService::get()
To search for items, use the search()
method.
Multiple collections can exist in the Secret Service, each of which
contains secret items. To access the list of Collections, use
get_collections()
.
Certain actions on the Secret Service require user prompting to complete,
such as creating a collection, or unlocking a collection. When such a
prompt is necessary, then a SecretPrompt object is created by libsecret,
and passed to the secret_service_prompt() method. In this way it is handled
automatically.
Methods
impl SecretService
fn get() -> SecretResult<Self>
Constructs a new SecretService which has established a session and whose collections are loaded. The underlying FFI object might be identical for multiple instances of this struct.
fn is_session_established(&self) -> bool
Returns if a session to the SecretService is currently established.
fn are_collections_loaded(&self) -> bool
Returns if the Service's collections are loaded.
fn get_session_algorithms(&self) -> String
Get the set of algorithms being used to transfer secrets between this secret service proxy and the Secret Service itself. The contained String has the format "algorithm-algorithm-algorithm-..."
fn get_collections(&self) -> Vec<SecretCollection>
Get the collections of the Service. A collection contains multiple SecretItems.
fn search(&self, attributes: &HashMap<String, String>) -> SecretResult<Vec<SecretItem>>
Search for items matching the attributes. All collections are searched. The attributes should be a table of string keys and string values.
fn store(&self, attributes: &HashMap<String, String>, collection: Option<&str>, label: &str, value: &SecretValue) -> SecretResult<()>
Store a secret value in the secret service.
The attributes
should be a set of key and value string pairs.
If the attributes match a secret item already stored in the collection,
then the item will be updated with these new values.
collection
is a collection alias, or None
to store the value in the
default collection (TODO: What about session storage?)
label
specifies a label for the secret.
value
is the actual secret to store. This can be created with
SecretValue::new()
.
fn clear(&self, attributes: &HashMap<String, String>) -> SecretResult<()>
Remove unlocked items which match the attributes from the secret service. The attributes should be a set of key and value string pairs.
fn ensure_session(&self) -> SecretResult<()>
Ensures that a session is established.
fn load_collections(&self) -> SecretResult<()>
Ensures that the collections are loaded.