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