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 42 43 44 45 46 47 48 49
//! Data types for the control structure of a [`CryptoBox`](crate::CryptoBox)
use std::sync::Arc;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
use crate::crypto::DerivedKey;
/// Can contain any control structure in a [`CryptoBox`](crate::CryptoBox)
#[derive(Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Control {
/// Stores the default settings for the [`CryptoBox`](crate::CryptoBox)
///
/// This lives at the empty string (`""`) path in the root namespace
Settings(Settings),
/// List of namespaces in the [`CryptoBox`](crate::CryptoBox)
///
/// This lives at the `"namespaces"` path in the root namespace
Namespaces(Namespaces),
}
/// Initial configuration settings for a [`CryptoBox`](crate::CryptoBox)
#[derive(Debug, Hash, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct Settings {
/// Compression level for this box
pub compression: Option<i32>,
/// Default maximum write cache entries for this box
pub max_cache_entries: Option<usize>,
}
/// The namespaces control structure
#[derive(Clone, Serialize, Deserialize)]
pub struct Namespaces {
/// The list of namespaces
pub namespaces: Vec<Namespace>,
}
/// Information about a Namespace
#[derive(Hash, Clone, Serialize, Deserialize)]
pub struct Namespace {
/// The name of this namespace
pub name: String,
/// The derived key for this namespace
pub key: Arc<DerivedKey>,
/// The [`Uuid`] of this namespace
pub uuid: Uuid,
}