pub struct SqliteConfig {
pub path: Option<PathBuf>,
pub synchronous: SynchronousMode,
pub journal_mode: JournalMode,
pub foreign_keys: bool,
pub busy_timeout_ms: u32,
pub cache_size: i32,
pub page_size: u32,
pub read_only: bool,
pub create_if_missing: bool,
}Expand description
SQLite 配置
Fields§
§path: Option<PathBuf>数据库路径(None 表示内存数据库)
synchronous: SynchronousMode同步模式
journal_mode: JournalMode日志模式
foreign_keys: bool是否启用外键约束
busy_timeout_ms: u32繁忙超时(毫秒)
cache_size: i32缓存大小(页数,负数表示 KB)
page_size: u32页大小(字节)
read_only: bool是否只读
create_if_missing: bool创建时如果不存在
Implementations§
Source§impl SqliteConfig
impl SqliteConfig
Sourcepub fn performance() -> Self
pub fn performance() -> Self
创建性能优先配置
- WAL 模式
- 异步同步
- 大缓存
Sourcepub fn with_synchronous(self, mode: SynchronousMode) -> Self
pub fn with_synchronous(self, mode: SynchronousMode) -> Self
设置同步模式
Sourcepub fn with_journal_mode(self, mode: JournalMode) -> Self
pub fn with_journal_mode(self, mode: JournalMode) -> Self
设置日志模式
Sourcepub fn with_foreign_keys(self, enabled: bool) -> Self
pub fn with_foreign_keys(self, enabled: bool) -> Self
设置外键约束
Sourcepub fn with_busy_timeout(self, ms: u32) -> Self
pub fn with_busy_timeout(self, ms: u32) -> Self
设置繁忙超时
Sourcepub fn with_read_only(self, read_only: bool) -> Self
pub fn with_read_only(self, read_only: bool) -> Self
设置只读模式
Sourcepub fn to_pragmas(&self) -> Vec<String>
pub fn to_pragmas(&self) -> Vec<String>
生成 PRAGMA 语句列表
Sourcepub fn path_string(&self) -> String
pub fn path_string(&self) -> String
获取数据库路径字符串(用于 rusqlite)
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 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