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
34
35
36
37
38
39
40
41
#![warn(missing_docs)]
//! Rust bindings to libsecret.
//! Many unix/linux systems utilize a secret service to securely store 
//! and retrieve passwords. Examples for such a SecretService are gnome-keyring
//! and kwallet.
//! This library provides methods to access the system's secret service in a 
//! platform independent matter. This is done by linking to [libsecret]
//! (https://developer.gnome.org/libsecret/0.18/), a library developed by the 
//! gnome project.

extern crate libc;
extern crate glib;
extern crate secret_sys;

mod secret_service;
mod secret_collection;
mod secret_item;
mod secret_value;
mod util;

pub use self::secret_sys as ffi;
pub use self::secret_service::SecretService;
pub use self::secret_collection::SecretCollection;
pub use self::secret_item::SecretItem;
pub use self::secret_value::SecretValue;

use glib::Error;
use glib::object::Wrapper;

/// A Result which may contain an error from the SecretService backend.
pub type SecretResult<T> = Result<T, Error>;

/// This Trait is implemented by objects which can be locked and unlocked
pub trait Lock<T: Wrapper> {

    /// Lock the object.
    fn lock(&self) -> SecretResult<Vec<T>>;

    /// Unlock the object
    fn unlock(&self) -> SecretResult<Vec<T>>;
}