Skip to main content

folk_builder/
config.rs

1use serde::Deserialize;
2
3#[derive(Debug, Clone, Deserialize)]
4pub struct BuildConfig {
5    pub build: BuildMeta,
6    #[serde(default)]
7    pub plugin: Vec<PluginEntry>,
8}
9
10#[derive(Debug, Clone, Deserialize)]
11pub struct BuildMeta {
12    pub output: String,
13    #[serde(default = "default_rust_version")]
14    pub rust_version: String,
15    /// Path to folk-ext crate (for local builds). If not set, uses crates.io.
16    pub folk_ext_path: Option<String>,
17    /// Path to folk-api crate (for local builds with unpublished changes).
18    pub folk_api_path: Option<String>,
19}
20
21fn default_rust_version() -> String {
22    "1.85".into()
23}
24
25#[derive(Debug, Clone, Deserialize)]
26pub struct PluginEntry {
27    pub crate_name: String,
28    pub version: Option<String>,
29    pub path: Option<String>,
30    pub git: Option<String>,
31    #[serde(default)]
32    pub config_key: String,
33}
34
35pub fn load(path: &str) -> anyhow::Result<BuildConfig> {
36    let text = std::fs::read_to_string(path)?;
37    Ok(toml::from_str(&text)?)
38}