Skip to main content

Database

Struct Database 

Source
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

Source

pub fn begin_read(&self) -> ReadTxn<'_>

Begin a read-only transaction with snapshot isolation.

Source

pub fn begin_write(&self) -> Result<WriteTxn<'_>>

Begin a read-write transaction. Only one can be active at a time.

Source

pub fn stats(&self) -> DbStats

Get database statistics from the current commit slot.

Source

pub fn data_path(&self) -> &Path

Path to the data file.

Source

pub fn key_path(&self) -> &Path

Path to the key file.

Source

pub fn reader_count(&self) -> usize

Number of currently active readers.

Source

pub fn change_passphrase( &self, old_passphrase: &[u8], new_passphrase: &[u8], ) -> Result<()>

Change the database passphrase (re-wraps REK, no page re-encryption).

Source

pub fn integrity_check(&self) -> Result<IntegrityReport>

Run an integrity check on the database.

Source

pub fn backup(&self, dest_path: &Path) -> Result<()>

Create a hot backup via MVCC snapshot. Also copies the key file.

Source

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.

Source

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

pub fn compact(&self, dest_path: &Path) -> Result<()>

Compact the database into a new file. Also copies the key file.

Source§

impl Database

Source

pub fn audit_log_path(&self) -> Option<PathBuf>

Path to the audit log file, if audit logging is enabled.

Source

pub fn verify_audit_log(&self) -> Result<AuditVerifyResult>

Verify the audit log’s HMAC chain integrity.

Source§

impl Database

Source

pub fn node_id(&self) -> Result<NodeId>

Get or create a persistent NodeId for this database.

Source

pub fn sync_to(&self, addr: &str, sync_key: &SyncKey) -> Result<SyncOutcome>

Push local named tables to a remote peer.

Source

pub fn handle_sync( &self, stream: TcpStream, sync_key: &SyncKey, ) -> Result<SyncOutcome>

Handle an incoming sync session from a remote peer.

Trait Implementations§

Source§

impl Debug for Database

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Database

Available on crate feature audit-log only.
Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Database

Source§

impl Sync for Database

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V