pub type StorageResult<T> = Result<T, StorageError>;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum StorageError {
NotAvailable,
RepositoryNotFound(String),
MigrationFailed(String),
TransactionFailed(String),
TransactionsUnsupported,
BackupFailed(String),
InvalidPath(String),
SecurityFailed(String),
AuthUnavailable(String),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StorageStatus {
Online,
Degraded,
ReadOnly,
Offline,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StorageHealth {
pub status: StorageStatus,
pub message: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RepositoryName(
pub String,
);
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MigrationId(
pub String,
);
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BackupDescriptor {
pub name: String,
pub created_at_ms: u64,
}
pub trait Transaction {
fn commit(&mut self) -> StorageResult<()>;
fn rollback(&mut self) -> StorageResult<()>;
}
pub trait Repository {
fn name(&self) -> &RepositoryName;
}
pub trait Migration {
fn id(&self) -> &MigrationId;
fn apply(&self, tx: &mut dyn Transaction) -> StorageResult<()>;
}
pub trait StorageProvider {
fn status(&self) -> StorageStatus;
fn health(&self) -> StorageHealth;
fn open(&mut self) -> StorageResult<()>;
fn close(&mut self) -> StorageResult<()>;
fn begin_transaction(&mut self) -> StorageResult<Box<dyn Transaction>>;
fn list_backups(&self) -> Vec<BackupDescriptor>;
}
#[path = "storage_auth_remote.rs"]
mod storage_auth_remote;
#[path = "storage_backup.rs"]
mod storage_backup;
#[path = "storage_backup_list.rs"]
mod storage_backup_list;
#[path = "storage_file.rs"]
mod storage_file;
#[path = "storage_file_fs.rs"]
mod storage_file_fs;
#[path = "storage_tree.rs"]
mod storage_tree;
pub use storage_auth_remote::{
data_claims, make_auth_request, now_ms, open_remote_request, open_remote_response,
process_remote_request, seal_remote_request, seal_remote_response, transport_claims,
validate_auth_resource, AuthRemoteRequest, AuthRemoteResponse, RemoteAuthStorageClient,
AUTH_REMOTE_ENDPOINT, AUTH_REMOTE_SCHEMA, DEFAULT_AUTH_REMOTE_MAX_BYTES,
DEFAULT_AUTH_REMOTE_TIMEOUT_MS, DEFAULT_AUTH_REMOTE_TTL_MS,
};
pub use storage_backup::{
StorageBackupManifestFileV1, StorageBackupManifestV1, STORAGE_BACKUP_FORMAT_V1,
};
#[path = "storage_dnt.rs"]
mod storage_dnt;
pub use storage_dnt::{
DntFileObjectStore, DntFileSecretStore, DntFileSnapshotStore, SealedObjectStore,
SealedSecretStore, SealedSnapshotStore, SealedStoragePolicy,
};
pub use storage_file::FileStorageProvider;
#[cfg(test)]
pub(crate) use storage_file_fs::tmp_path_for;
#[cfg(test)]
#[path = "storage_backup_tests.rs"]
mod storage_backup_tests;
#[cfg(test)]
#[path = "storage_tests.rs"]
mod storage_tests;