fts_sqlite/config.rs
1//! Configuration types for the SQLite database connection.
2//!
3//! This module provides configuration options for establishing and managing
4//! SQLite database connections.
5
6use serde::{Deserialize, Serialize};
7use std::path::PathBuf;
8
9/// Configuration for SQLite database connections.
10///
11/// This struct controls how the database connection is established.
12///
13/// # Examples
14///
15/// ```
16/// use fts_sqlite::config::SqliteConfig;
17/// use std::path::PathBuf;
18///
19/// // In-memory database (default)
20/// let config = SqliteConfig::default();
21///
22/// // File-based database
23/// let config = SqliteConfig {
24/// database_path: Some(PathBuf::from("flow_trading.db")),
25/// create_if_missing: true,
26/// };
27/// ```
28#[derive(Debug, Clone, Deserialize, Serialize)]
29pub struct SqliteConfig {
30 /// Database file path. If None, uses in-memory database
31 pub database_path: Option<PathBuf>,
32
33 /// Whether to create the database if it doesn't exist
34 #[serde(default = "default_true")]
35 pub create_if_missing: bool,
36}
37
38fn default_true() -> bool {
39 true
40}
41
42impl Default for SqliteConfig {
43 fn default() -> Self {
44 Self {
45 database_path: None,
46 create_if_missing: true,
47 }
48 }
49}