use serde::Deserialize; use std::{collections::HashMap, fmt::Debug, path::PathBuf}; mod post; pub use post::*; mod misc; pub use misc::*; pub static INIT_DB_TOML: &str = include_str!("./config.toml"); #[test] #[expect(clippy::unwrap_used)] fn init_db_toml_valid() { toml::from_str::(INIT_DB_TOML).expect("INIT_DB_TOML should be valid TOML"); } #[derive(Debug, Clone, Deserialize)] pub struct ConfigToml { pub dataset: DatasetConfig, pub schema: HashMap, pub fts: Option, } #[derive(Debug, Clone, Deserialize)] pub struct DatasetConfig { /// Must be unique pub name: Label, /// Root dir for indices pub working_dir: Option, /// Where to find this field pub source: HashMap, /// How to post-process this field #[serde(default)] pub post: Vec, } #[derive(Debug, Clone, Deserialize)] #[serde(tag = "type")] #[serde(rename_all = "lowercase")] pub enum Source { /// A directory of FLAC files Flac { path: OneOrMany }, } // // MARK: schema // #[derive(Debug, Clone, Deserialize)] pub struct FieldSpec { /// The type of this field pub r#type: FieldType, /// How to find this field in a data entry pub path: OneOrMany, /// How to post-process this field #[serde(default)] pub post: Vec, } #[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq)] #[serde(rename_all = "lowercase")] pub enum FieldType { Text, } // // MARK: fts // #[derive(Debug, Clone, Deserialize, Default)] pub struct DatasetFts { #[serde(alias = "field")] pub fields: HashMap, } #[derive(Debug, Clone, Deserialize)] pub struct FtsIndexField { pub tokenize: bool, }