KeyBoxen 0.1.0

Standalone secret-service daemon for window managers
// Copyright (C) 2022 KeyBoxen Authors
// SPDX-License-Identifier: GPL-3.0-or-later

//! DBus service module
//!
//! This module deals with [serving the secrets][spec] over the dbus
//! interface.
//!
//! [spec]: https://specifications.freedesktop.org/secret-service/latest/

mod attribute;
mod collection;
mod item;
mod lock;
mod root;
mod transaction;

use std::collections::HashMap;

/// Service root object
///
/// The singleton DBus object that represents the entire service on
/// the connection. Check [root] module for details.
pub struct Service {
    collections: HashMap<String, Collection>,
    items: HashMap<String, Item>,
    attributes: Vec<Attribute>,
}

/// Attribute object
///
/// Lookup attributes are key-value pairs stored by clients and used
/// for searching and identifying items. Refer [attribute] module for
/// more details.
pub struct Attribute {
    key: String,
    value: String,
    collection_name: String,
    item_label: String,
}

/// Collection object
///
/// A collection is a group of items that is either unlocked with a
/// key stored as an array of bytes, or is locked. Refer [collection]
/// module for more details.
pub enum Collection {
    Locked,
    Unlocked(Vec<u8>),
}

/// Item object
///
/// An item is a container for secrets along with parameters needed to
/// unlock it. The secret is stored on disk in encrypted form.
/// Refer [item] module for more details.
pub struct Item {
    collection: String,
    locked: bool,
    ask: bool,
}

/// DBus Secret
///
/// This data structure represents secrets that are exchanged over
/// DBus. Refer [structure documentation][transaction::DBusSecret] for
/// more details.
pub use transaction::DBusSecret;

/// DBus Error
///
/// This data structure represents the errors that may need to be
/// communicated to clients over the DBus connection. Refer [enum
/// documentation][transaction::DBusErrorKind] for more details.
pub use transaction::DBusErrorKind;