SqliteConfig

Struct SqliteConfig 

Source
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

Source

pub fn memory() -> Self

创建内存数据库配置

Source

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

创建文件数据库配置

Source

pub fn performance() -> Self

创建性能优先配置

  • WAL 模式
  • 异步同步
  • 大缓存
Source

pub fn durable() -> Self

创建持久性优先配置

  • 完全同步
  • 启用外键
Source

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

设置数据库路径

Source

pub fn with_synchronous(self, mode: SynchronousMode) -> Self

设置同步模式

Source

pub fn with_journal_mode(self, mode: JournalMode) -> Self

设置日志模式

Source

pub fn with_foreign_keys(self, enabled: bool) -> Self

设置外键约束

Source

pub fn with_busy_timeout(self, ms: u32) -> Self

设置繁忙超时

Source

pub fn with_read_only(self, read_only: bool) -> Self

设置只读模式

Source

pub fn to_pragmas(&self) -> Vec<String>

生成 PRAGMA 语句列表

Source

pub fn path_string(&self) -> String

获取数据库路径字符串(用于 rusqlite)

Source

pub fn is_memory(&self) -> bool

判断是否为内存数据库

Trait Implementations§

Source§

impl Clone for SqliteConfig

Source§

fn clone(&self) -> SqliteConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SqliteConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SqliteConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more