Skip to main content

DatabaseBuilder

Struct DatabaseBuilder 

Source
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

Source

pub fn new(path: impl Into<PathBuf>) -> Self

Source

pub fn passphrase(self, passphrase: &[u8]) -> Self

Source

pub fn key_path(self, path: impl Into<PathBuf>) -> Self

Source

pub fn argon2_profile(self, profile: Argon2Profile) -> Self

Source

pub fn cache_size(self, pages: usize) -> Self

Source

pub fn cipher(self, cipher: CipherId) -> Self

Source

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().

Source

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).

Source

pub fn audit_config(self, config: AuditConfig) -> Self

Configure the audit log.

Default: enabled with 10 MB max file size and 3 rotated files.

Source

pub fn create(self) -> Result<Database>

Create a new database. Fails if the data file already exists.

Source

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.

Source

pub fn open(self) -> Result<Database>

Open an existing database. Fails if the data file does not exist.

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