config-easy 0.2.1

A small interactive settings menu for command-line Rust applications
Documentation
use std::error::Error;

use crate::SettingRow;

/// A database query description for loading and updating settings.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct SettingsQuery<'a> {
    pub table: &'a str,
    pub key_column: &'a str,
    pub value_column: &'a str,
    pub order_by: &'a str,
}

/// A storage backend that can load and update string settings.
pub trait SettingsStore {
    fn load_settings(
        &self,
        query: &SettingsQuery<'_>,
    ) -> Result<Vec<SettingRow>, Box<dyn Error + Send + Sync>>;

    fn update_setting(
        &self,
        query: &SettingsQuery<'_>,
        key: &str,
        value: &str,
    ) -> Result<(), Box<dyn Error + Send + Sync>>;
}