#![deny(missing_docs)]
#![forbid(unsafe_code)]
#![cfg_attr(all(doc, CHANNEL_NIGHTLY), feature(doc_auto_cfg))]
use sos_core::{
crypto::{AccessKey, Cipher, KeyDerivation},
events::WriteEvent,
AccountId, VaultFlags, VaultId,
};
use sos_vault::Vault;
mod database;
mod error;
#[cfg(feature = "files")]
pub mod files;
mod filesystem;
pub(crate) mod folder_sync;
mod secret_storage;
mod storage;
mod sync;
mod traits;
pub use error::Error;
pub use storage::ClientStorage;
pub use traits::{
ClientAccountStorage, ClientBaseStorage, ClientDeviceStorage,
ClientFolderStorage, ClientSecretStorage,
};
pub(crate) use traits::{ClientEventLogStorage, ClientVaultStorage};
pub(crate) type Result<T> = std::result::Result<T, Error>;
#[cfg(feature = "files")]
use sos_external_files::FileMutationEvent;
#[derive(Debug, Default)]
pub struct NewFolderOptions {
pub name: String,
pub flags: Option<VaultFlags>,
pub key: Option<AccessKey>,
pub cipher: Option<Cipher>,
pub kdf: Option<KeyDerivation>,
}
impl NewFolderOptions {
pub fn new(name: String) -> Self {
Self {
name,
flags: None,
key: None,
cipher: None,
kdf: None,
}
}
}
#[derive(Default)]
pub struct AccountPack {
pub account_id: AccountId,
pub identity_vault: Vault,
pub folders: Vec<Vault>,
}
#[derive(Default, Clone)]
pub struct AccessOptions {
pub folder: Option<VaultId>,
pub destination: Option<VaultId>,
#[cfg(feature = "files")]
pub file_progress:
Option<tokio::sync::mpsc::Sender<sos_external_files::FileProgress>>,
}
impl From<&VaultId> for AccessOptions {
fn from(value: &VaultId) -> Self {
Self {
folder: Some(*value),
..Default::default()
}
}
}
impl From<Option<&VaultId>> for AccessOptions {
fn from(value: Option<&VaultId>) -> Self {
Self {
folder: value.copied(),
..Default::default()
}
}
}
#[doc(hidden)]
pub struct StorageChangeEvent {
pub event: WriteEvent,
#[cfg(feature = "files")]
pub file_events: Vec<FileMutationEvent>,
}