Skip to main content

config_easy/
store.rs

1use std::error::Error;
2
3use crate::SettingRow;
4
5/// A database query description for loading and updating settings.
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub struct SettingsQuery<'a> {
8    pub table: &'a str,
9    pub key_column: &'a str,
10    pub value_column: &'a str,
11    pub order_by: &'a str,
12}
13
14/// A storage backend that can load and update string settings.
15pub trait SettingsStore {
16    fn load_settings(
17        &self,
18        query: &SettingsQuery<'_>,
19    ) -> Result<Vec<SettingRow>, Box<dyn Error + Send + Sync>>;
20
21    fn update_setting(
22        &self,
23        query: &SettingsQuery<'_>,
24        key: &str,
25        value: &str,
26    ) -> Result<(), Box<dyn Error + Send + Sync>>;
27}