pub struct SqliteConfig {
pub path: DbPath,
pub flags: OpenFlags,
pub journal_mode: JournalMode,
pub synchronous_mode: SynchronousMode,
pub temp_store: TempStore,
pub cache_size: u32,
pub wal_autocheckpoint: u32,
pub page_size: u32,
pub mmap_size: u64,
}Expand description
Configuration for a SQLite storage backend.
Fields§
§path: DbPath§flags: OpenFlags§journal_mode: JournalMode§synchronous_mode: SynchronousMode§temp_store: TempStore§cache_size: u32§wal_autocheckpoint: u32§page_size: u32§mmap_size: u64Implementations§
Source§impl SqliteConfig
impl SqliteConfig
Sourcepub fn new<P: AsRef<Path>>(path: P) -> Self
pub fn new<P: AsRef<Path>>(path: P) -> Self
Balanced production defaults.
- WAL journal + NORMAL synchronous: durable across crashes, one fsync per commit
- 8 MiB page cache (2000 pages * 4 KiB) covers a typical hot working set
- 64 MiB mmap window for fast cold reads
- 4 KiB pages match the kernel page size
- Override
cache_size/mmap_sizevia the fluent builder for unusual workloads.
Sourcepub fn safe<P: AsRef<Path>>(path: P) -> Self
pub fn safe<P: AsRef<Path>>(path: P) -> Self
Safety-first configuration optimized for data integrity.
- WAL journal mode for crash recovery
- FULL synchronous mode forces fsync on every commit
- FILE temp store so a big sort cannot blow up RSS
- mmap disabled: reads must go through the fsync-respecting page cache
Sourcepub fn fast<P: AsRef<Path>>(path: P) -> Self
pub fn fast<P: AsRef<Path>>(path: P) -> Self
High-performance configuration optimized for throughput.
- WAL journal so a crash can still replay batched writes
- OFF synchronous mode skips fsync entirely (data may be lost on power loss)
- 16 KiB pages cut per-page metadata overhead for large tables
- 160 MiB page cache (10000 pages * 16 KiB) and 256 MiB mmap window
- WAL allowed to grow up to 10000 pages before checkpoint
Sourcepub fn tmpfs() -> Self
pub fn tmpfs() -> Self
Tmpfs-backed configuration for ephemeral database storage. Uses /tmp (often tmpfs). The DB file already lives in RAM, so mmap is disabled; mmap’ing a tmpfs file would just give the process a second resident copy of every page.
Sourcepub fn in_memory() -> Self
pub fn in_memory() -> Self
In-memory configuration backed by /dev/shm on Linux, temp dir elsewhere.
Same reasoning as tmpfs: the file lives in RAM, so mmap is disabled
to avoid the second resident copy.
Sourcepub fn test() -> Self
pub fn test() -> Self
Test configuration with an in-memory database and minimal cache. Uses /dev/shm on Linux, temp dir on other platforms.
pub fn path<P: AsRef<Path>>(self, path: P) -> Self
pub fn flags(self, flags: OpenFlags) -> Self
pub fn journal_mode(self, mode: JournalMode) -> Self
pub fn synchronous_mode(self, mode: SynchronousMode) -> Self
pub fn temp_store(self, store: TempStore) -> Self
pub fn cache_size(self, size_kb: u32) -> Self
pub fn wal_autocheckpoint(self, pages: u32) -> Self
Trait Implementations§
Source§impl Clone for SqliteConfig
impl Clone for SqliteConfig
Source§fn clone(&self) -> SqliteConfig
fn clone(&self) -> SqliteConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SqliteConfig
impl Debug for SqliteConfig
Auto Trait Implementations§
impl Freeze for SqliteConfig
impl RefUnwindSafe for SqliteConfig
impl Send for SqliteConfig
impl Sync for SqliteConfig
impl Unpin for SqliteConfig
impl UnsafeUnpin for SqliteConfig
impl UnwindSafe for SqliteConfig
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