Skip to main content

modo_db/
config.rs

1use serde::Deserialize;
2
3/// Database configuration, deserialized from YAML via `modo::config::load()`.
4///
5/// Backend is auto-detected from the URL scheme (`sqlite://` or `postgres://`).
6/// Irrelevant fields are silently ignored for the active backend.
7#[derive(Debug, Clone, Deserialize)]
8#[serde(default)]
9pub struct DatabaseConfig {
10    /// Connection URL (e.g., `sqlite://data.db?mode=rwc` or `postgres://localhost/myapp`).
11    pub url: String,
12    /// Maximum number of connections in the pool.
13    pub max_connections: u32,
14    /// Minimum number of connections in the pool.
15    pub min_connections: u32,
16}
17
18impl Default for DatabaseConfig {
19    fn default() -> Self {
20        Self {
21            url: "sqlite://data.db?mode=rwc".to_string(),
22            max_connections: 5,
23            min_connections: 1,
24        }
25    }
26}