sos_client_storage/
lib.rs1#![deny(missing_docs)]
2#![forbid(unsafe_code)]
3#![cfg_attr(all(doc, CHANNEL_NIGHTLY), feature(doc_auto_cfg))]
4use sos_core::{
6 crypto::{AccessKey, Cipher, KeyDerivation},
7 events::WriteEvent,
8 AccountId, VaultFlags, VaultId,
9};
10use sos_vault::Vault;
11
12mod database;
13mod error;
14#[cfg(feature = "files")]
15pub mod files;
16mod filesystem;
17pub(crate) mod folder_sync;
18mod secret_storage;
19mod storage;
20mod sync;
21mod traits;
22
23pub use error::Error;
24pub use storage::ClientStorage;
25pub use traits::{
26 ClientAccountStorage, ClientBaseStorage, ClientDeviceStorage,
27 ClientFolderStorage, ClientSecretStorage,
28};
29pub(crate) use traits::{ClientEventLogStorage, ClientVaultStorage};
30
31pub(crate) type Result<T> = std::result::Result<T, Error>;
33
34#[cfg(feature = "files")]
35use sos_external_files::FileMutationEvent;
36
37#[derive(Debug, Default)]
39pub struct NewFolderOptions {
40 pub name: String,
42 pub flags: Option<VaultFlags>,
44 pub key: Option<AccessKey>,
46 pub cipher: Option<Cipher>,
48 pub kdf: Option<KeyDerivation>,
50}
51
52impl NewFolderOptions {
53 pub fn new(name: String) -> Self {
55 Self {
56 name,
57 flags: None,
58 key: None,
59 cipher: None,
60 kdf: None,
61 }
62 }
63}
64
65#[derive(Default)]
67pub struct AccountPack {
68 pub account_id: AccountId,
70 pub identity_vault: Vault,
72 pub folders: Vec<Vault>,
75}
76
77#[derive(Default, Clone)]
79pub struct AccessOptions {
80 pub folder: Option<VaultId>,
86
87 pub destination: Option<VaultId>,
92
93 #[cfg(feature = "files")]
95 pub file_progress:
96 Option<tokio::sync::mpsc::Sender<sos_external_files::FileProgress>>,
97}
98
99impl From<&VaultId> for AccessOptions {
100 fn from(value: &VaultId) -> Self {
101 Self {
102 folder: Some(*value),
103 ..Default::default()
104 }
105 }
106}
107
108impl From<Option<&VaultId>> for AccessOptions {
109 fn from(value: Option<&VaultId>) -> Self {
110 Self {
111 folder: value.copied(),
112 ..Default::default()
113 }
114 }
115}
116
117#[doc(hidden)]
120pub struct StorageChangeEvent {
121 pub event: WriteEvent,
123 #[cfg(feature = "files")]
125 pub file_events: Vec<FileMutationEvent>,
126}