pub struct DatabaseBuilder { /* private fields */ }Expand description
Builder for creating or opening a Citadel database.
§Examples
use citadel::{DatabaseBuilder, Argon2Profile};
let db = DatabaseBuilder::new("mydb.citadel")
.passphrase(b"secret")
.cache_size(512)
.create()
.unwrap();Implementations§
Source§impl DatabaseBuilder
impl DatabaseBuilder
pub fn new(path: impl Into<PathBuf>) -> Self
pub fn passphrase(self, passphrase: &[u8]) -> Self
pub fn key_path(self, path: impl Into<PathBuf>) -> Self
pub fn argon2_profile(self, profile: Argon2Profile) -> Self
pub fn cache_size(self, pages: usize) -> Self
pub fn cipher(self, cipher: CipherId) -> Self
Sourcepub fn kdf_algorithm(self, algorithm: KdfAlgorithm) -> Self
pub fn kdf_algorithm(self, algorithm: KdfAlgorithm) -> Self
Set the key derivation function algorithm.
Default: Argon2id. Use Pbkdf2HmacSha256 for FIPS 140-3 compliance.
When using PBKDF2, the Argon2 profile is ignored and iterations are
controlled by pbkdf2_iterations().
Sourcepub fn pbkdf2_iterations(self, iterations: u32) -> Self
pub fn pbkdf2_iterations(self, iterations: u32) -> Self
Set the number of PBKDF2 iterations (only used when KDF is PBKDF2).
Default: 600,000 (OWASP 2024 minimum for PBKDF2-HMAC-SHA256).
Sourcepub fn audit_config(self, config: AuditConfig) -> Self
pub fn audit_config(self, config: AuditConfig) -> Self
Configure the audit log.
Default: enabled with 10 MB max file size and 3 rotated files.
Sourcepub fn create(self) -> Result<Database>
pub fn create(self) -> Result<Database>
Create a new database. Fails if the data file already exists.
Sourcepub fn create_in_memory(self) -> Result<Database>
pub fn create_in_memory(self) -> Result<Database>
Create a new in-memory database (volatile, no file I/O).
Data exists only for the lifetime of the returned Database.
Useful for testing, caching, and WASM environments.
Auto Trait Implementations§
impl Freeze for DatabaseBuilder
impl RefUnwindSafe for DatabaseBuilder
impl Send for DatabaseBuilder
impl Sync for DatabaseBuilder
impl Unpin for DatabaseBuilder
impl UnsafeUnpin for DatabaseBuilder
impl UnwindSafe for DatabaseBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more