use serde::Deserialize; use std::{collections::HashMap, fmt::Debug, path::PathBuf}; mod post; pub use post::*; mod misc; pub use misc::*; use crate::objectpath::ObjectPath; pub mod objectpath; pub static INIT_DB_TOML: &str = include_str!("./config.toml"); fn default_true() -> bool { true } #[test] #[expect(clippy::expect_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 files Filesystem { /// The directories to scan. /// Must be relative. #[serde(alias = "paths")] path: OneOrMany, /// If true, all toml files are ignored. /// Metadata can be added to any file using a {filename}.toml. /// /// If false, toml files are treated as regular files /// and sidecar metadata is disabled. #[serde(default = "default_true")] sidecars: bool, }, } // // 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, }