pub struct Config {
pub sync_mode: SyncMode,
pub reader_threads: NonZeroUsize,
pub resize_algorithm: ResizeAlgorithm,
/* private fields */
}
Expand description
Database Env
configuration.
This is the struct passed to Env::open
that
allows the database to be configured in various ways.
For construction, use ConfigBuilder
.
Fields§
§sync_mode: SyncMode
Disk synchronization mode.
reader_threads: NonZeroUsize
Database reader thread count.
Set the number of slots in the reader table.
This is only used in LMDB, see here.
By default, this value is READER_THREADS_DEFAULT
.
resize_algorithm: ResizeAlgorithm
Database memory map resizing algorithm.
This is used as the default fallback, but
custom algorithms can be used as well with
Env::resize_map
.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new(db_directory: Cow<'static, Path>) -> Self
pub fn new(db_directory: Cow<'static, Path>) -> Self
Create a new Config
with sane default settings.
The Config::db_directory
must be passed.
All other values will be Default::default
.
use cuprate_database::{config::*, resize::*, DATABASE_DATA_FILENAME};
let tmp_dir = tempfile::tempdir().unwrap();
let db_directory = tmp_dir.path().to_owned();
let config = Config::new(db_directory.clone().into());
assert_eq!(*config.db_directory(), db_directory);
assert!(config.db_file().starts_with(db_directory));
assert!(config.db_file().ends_with(DATABASE_DATA_FILENAME));
assert_eq!(config.sync_mode, SyncMode::default());
assert_eq!(config.reader_threads, READER_THREADS_DEFAULT);
assert_eq!(config.resize_algorithm, ResizeAlgorithm::default());
Sourcepub const fn db_directory(&self) -> &Cow<'_, Path>
pub const fn db_directory(&self) -> &Cow<'_, Path>
Return the absolute Path
to the database directory.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialOrd for Config
impl PartialOrd for Config
impl StructuralPartialEq for Config
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 88 bytes