1pub 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_http.rs"]
123mod storage_auth_http;
124#[path = "storage_auth_remote.rs"]
125mod storage_auth_remote;
126#[path = "storage_backup.rs"]
127mod storage_backup;
128#[path = "storage_backup_io.rs"]
129mod storage_backup_io;
130#[path = "storage_backup_list.rs"]
131mod storage_backup_list;
132#[path = "storage_capability.rs"]
133mod storage_capability;
134#[path = "storage_file.rs"]
135mod storage_file;
136#[path = "storage_file_fs.rs"]
137mod storage_file_fs;
138#[path = "storage_tree.rs"]
139mod storage_tree;
140pub use storage_auth_remote::{
141 data_claims, make_auth_request, now_ms, open_remote_request, open_remote_response,
142 process_remote_request, seal_remote_request, seal_remote_response, transport_claims,
143 validate_auth_resource, AuthRemoteRequest, AuthRemoteResponse, RemoteAuthStorageClient,
144 AUTH_REMOTE_ENDPOINT, AUTH_REMOTE_SCHEMA, DEFAULT_AUTH_REMOTE_MAX_BYTES,
145 DEFAULT_AUTH_REMOTE_MAX_HTTP_RESPONSE_BYTES, DEFAULT_AUTH_REMOTE_MAX_PLAINTEXT_BYTES,
146 DEFAULT_AUTH_REMOTE_MAX_SEALED_BYTES, DEFAULT_AUTH_REMOTE_TIMEOUT_MS,
147 DEFAULT_AUTH_REMOTE_TTL_MS,
148};
149pub use storage_backup::{
150 StorageBackupManifestFileV1, StorageBackupManifestV1, MAX_STORAGE_SNAPSHOT_BYTES,
151 STORAGE_BACKUP_FORMAT_V1,
152};
153pub use storage_capability::{
154 StorageCapabilityCatalogV1, StorageCapabilityDescriptorV1, StorageCapabilityError,
155 StorageCapabilityProviderV1, StorageCapabilityRequirementsV1, StorageCapabilityV1,
156 MAX_STORAGE_CAPABILITY_PROVIDERS_V1, STORAGE_CAPABILITY_COUNT_V1,
157 STORAGE_CAPABILITY_DESCRIPTOR_VERSION_V1, STORAGE_REQUIRED_CAPABILITIES_SETTING,
158};
159#[path = "storage_dnt.rs"]
160mod storage_dnt;
161pub use storage_dnt::{
162 DntFileObjectStore, DntFileSecretStore, DntFileSnapshotStore, SealedObjectStore,
163 SealedSecretStore, SealedSnapshotStore, SealedStoragePolicy,
164};
165pub use storage_file::{
166 file_storage_capability_descriptor_v1, FileStorageProvider, DEFAULT_FILE_READ_MAX_BYTES,
167 MAX_STORAGE_BACKUP_FILE_BYTES,
168};
169#[cfg(test)]
170pub(crate) use storage_file_fs::tmp_path_for;
171
172#[cfg(test)]
173#[path = "storage_backup_tests.rs"]
174mod storage_backup_tests;
175#[cfg(test)]
176#[path = "storage_tests.rs"]
177mod storage_tests;