pub struct Database { /* private fields */ }Expand description
An open Citadel database (Send + Sync).
Exclusively locks the database file for its lifetime.
Implementations§
Source§impl Database
impl Database
Sourcepub fn begin_read(&self) -> ReadTxn<'_>
pub fn begin_read(&self) -> ReadTxn<'_>
Begin a read-only transaction with snapshot isolation.
Sourcepub fn begin_write(&self) -> Result<WriteTxn<'_>>
pub fn begin_write(&self) -> Result<WriteTxn<'_>>
Begin a read-write transaction. Only one can be active at a time.
Sourcepub fn reader_count(&self) -> usize
pub fn reader_count(&self) -> usize
Number of currently active readers.
Sourcepub fn change_passphrase(
&self,
old_passphrase: &[u8],
new_passphrase: &[u8],
) -> Result<()>
pub fn change_passphrase( &self, old_passphrase: &[u8], new_passphrase: &[u8], ) -> Result<()>
Change the database passphrase (re-wraps REK, no page re-encryption).
Sourcepub fn integrity_check(&self) -> Result<IntegrityReport>
pub fn integrity_check(&self) -> Result<IntegrityReport>
Run an integrity check on the database.
Sourcepub fn backup(&self, dest_path: &Path) -> Result<()>
pub fn backup(&self, dest_path: &Path) -> Result<()>
Create a hot backup via MVCC snapshot. Also copies the key file.
Sourcepub fn export_key_backup(
&self,
db_passphrase: &[u8],
backup_passphrase: &[u8],
dest_path: &Path,
) -> Result<()>
pub fn export_key_backup( &self, db_passphrase: &[u8], backup_passphrase: &[u8], dest_path: &Path, ) -> Result<()>
Export an encrypted key backup for disaster recovery.
Requires the current database passphrase. The backup can later restore
access via restore_key_from_backup if the database passphrase is lost.
Sourcepub fn restore_key_from_backup(
backup_path: &Path,
backup_passphrase: &[u8],
new_db_passphrase: &[u8],
db_path: &Path,
) -> Result<()>
pub fn restore_key_from_backup( backup_path: &Path, backup_passphrase: &[u8], new_db_passphrase: &[u8], db_path: &Path, ) -> Result<()>
Restore a key file from an encrypted backup (static — no Database needed).
Unwraps the REK using backup_passphrase, then creates a new key file
protected by new_db_passphrase.
Source§impl Database
impl Database
Sourcepub fn audit_log_path(&self) -> Option<PathBuf>
pub fn audit_log_path(&self) -> Option<PathBuf>
Path to the audit log file, if audit logging is enabled.
Sourcepub fn verify_audit_log(&self) -> Result<AuditVerifyResult>
pub fn verify_audit_log(&self) -> Result<AuditVerifyResult>
Verify the audit log’s HMAC chain integrity.
Source§impl Database
impl Database
Sourcepub fn sync_to(&self, addr: &str, sync_key: &SyncKey) -> Result<SyncOutcome>
pub fn sync_to(&self, addr: &str, sync_key: &SyncKey) -> Result<SyncOutcome>
Push local named tables to a remote peer.
Sourcepub fn handle_sync(
&self,
stream: TcpStream,
sync_key: &SyncKey,
) -> Result<SyncOutcome>
pub fn handle_sync( &self, stream: TcpStream, sync_key: &SyncKey, ) -> Result<SyncOutcome>
Handle an incoming sync session from a remote peer.