appcore_storage/
storage.rs1pub type StorageResult<T> = Result<T, StorageError>;
15
16#[derive(Debug, Clone, PartialEq, Eq)]
18pub enum StorageError {
19 NotAvailable,
21 RepositoryNotFound(String),
23 MigrationFailed(String),
25 TransactionFailed(String),
27 TransactionsUnsupported,
29 BackupFailed(String),
31 InvalidPath(String),
33 SecurityFailed(String),
35 AuthUnavailable(String),
37}
38
39#[derive(Debug, Clone, Copy, PartialEq, Eq)]
41pub enum StorageStatus {
42 Online,
44 Degraded,
46 ReadOnly,
48 Offline,
50}
51
52#[derive(Debug, Clone, PartialEq, Eq)]
54pub struct StorageHealth {
55 pub status: StorageStatus,
57 pub message: Option<String>,
59}
60
61#[derive(Debug, Clone, PartialEq, Eq, Hash)]
63pub struct RepositoryName(
64 pub String,
66);
67
68#[derive(Debug, Clone, PartialEq, Eq, Hash)]
70pub struct MigrationId(
71 pub String,
73);
74
75#[derive(Debug, Clone, PartialEq, Eq)]
77pub struct BackupDescriptor {
78 pub name: String,
80 pub created_at_ms: u64,
82}
83
84pub trait Transaction {
86 fn commit(&mut self) -> StorageResult<()>;
88 fn rollback(&mut self) -> StorageResult<()>;
90}
91
92pub trait Repository {
94 fn name(&self) -> &RepositoryName;
96}
97
98pub trait Migration {
100 fn id(&self) -> &MigrationId;
102 fn apply(&self, tx: &mut dyn Transaction) -> StorageResult<()>;
104}
105
106pub trait StorageProvider {
108 fn status(&self) -> StorageStatus;
110 fn health(&self) -> StorageHealth;
112 fn open(&mut self) -> StorageResult<()>;
114 fn close(&mut self) -> StorageResult<()>;
116 fn begin_transaction(&mut self) -> StorageResult<Box<dyn Transaction>>;
118 fn list_backups(&self) -> Vec<BackupDescriptor>;
120}
121
122#[path = "storage_auth_remote.rs"]
123mod storage_auth_remote;
124#[path = "storage_backup.rs"]
125mod storage_backup;
126#[path = "storage_backup_list.rs"]
127mod storage_backup_list;
128#[path = "storage_file.rs"]
129mod storage_file;
130#[path = "storage_file_fs.rs"]
131mod storage_file_fs;
132#[path = "storage_tree.rs"]
133mod storage_tree;
134pub use storage_auth_remote::{
135 data_claims, make_auth_request, now_ms, open_remote_request, open_remote_response,
136 process_remote_request, seal_remote_request, seal_remote_response, transport_claims,
137 validate_auth_resource, AuthRemoteRequest, AuthRemoteResponse, RemoteAuthStorageClient,
138 AUTH_REMOTE_ENDPOINT, AUTH_REMOTE_SCHEMA, DEFAULT_AUTH_REMOTE_MAX_BYTES,
139 DEFAULT_AUTH_REMOTE_TIMEOUT_MS, DEFAULT_AUTH_REMOTE_TTL_MS,
140};
141pub use storage_backup::{
142 StorageBackupManifestFileV1, StorageBackupManifestV1, STORAGE_BACKUP_FORMAT_V1,
143};
144#[path = "storage_dnt.rs"]
145mod storage_dnt;
146pub use storage_dnt::{
147 DntFileObjectStore, DntFileSecretStore, DntFileSnapshotStore, SealedObjectStore,
148 SealedSecretStore, SealedSnapshotStore, SealedStoragePolicy,
149};
150pub use storage_file::FileStorageProvider;
151#[cfg(test)]
152pub(crate) use storage_file_fs::tmp_path_for;
153
154#[cfg(test)]
155#[path = "storage_backup_tests.rs"]
156mod storage_backup_tests;
157#[cfg(test)]
158#[path = "storage_tests.rs"]
159mod storage_tests;