cuprate_database/config/mod.rs
1//! Database [`Env`](crate::Env) configuration.
2//!
3//! This module contains the main [`Config`]uration struct
4//! for the database [`Env`](crate::Env)ironment, and types
5//! related to configuration settings.
6//!
7//! The main constructor is the [`ConfigBuilder`].
8//!
9//! These configurations are processed at runtime, meaning
10//! the `Env` can/will dynamically adjust its behavior
11//! based on these values.
12//!
13//! # Example
14//! ```rust
15//! use cuprate_database::{
16//! ConcreteEnv, Env,
17//! config::{ConfigBuilder, SyncMode}
18//! };
19//!
20//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
21//! let db_dir = tempfile::tempdir()?;
22//!
23//! let config = ConfigBuilder::new(db_dir.path().to_path_buf().into())
24//! // Use the fastest sync mode.
25//! .sync_mode(SyncMode::Fast)
26//! // Build into `Config`
27//! .build();
28//!
29//! // Open the database using this configuration.
30//! let env = ConcreteEnv::open(config.clone())?;
31//! // It's using the config we provided.
32//! assert_eq!(env.config(), &config);
33//! # Ok(()) }
34//! ```
35
36#[expect(clippy::module_inception)]
37mod config;
38pub use config::{Config, ConfigBuilder, READER_THREADS_DEFAULT};
39
40mod sync_mode;
41pub use sync_mode::SyncMode;