2025-10-11 14:11:31 -07:00
|
|
|
use crate::actions::ActionDeclaration;
|
2025-10-12 22:39:56 -07:00
|
|
|
use crate::drivers::DriverDeclaration;
|
2025-10-14 12:47:33 -07:00
|
|
|
use crate::entries::EntryDeclaration;
|
2025-10-13 00:55:11 -07:00
|
|
|
use crate::extractors::ExtractorDeclaration;
|
2025-10-11 14:11:31 -07:00
|
|
|
use crate::generators::GeneratorDeclaration;
|
2025-10-14 12:47:33 -07:00
|
|
|
use crate::phases::PhasesConfiguration;
|
2025-10-01 18:25:49 -07:00
|
|
|
use serde::{Deserialize, Serialize};
|
2025-10-04 23:12:01 -07:00
|
|
|
use std::collections::BTreeMap;
|
2025-10-01 18:25:49 -07:00
|
|
|
|
2025-10-19 20:23:55 -07:00
|
|
|
/// The configuration loader mechanisms.
|
|
|
|
|
pub mod loader;
|
|
|
|
|
|
|
|
|
|
/// This is the latest version of the sprout configuration format.
|
|
|
|
|
/// This must be incremented when the configuration breaks compatibility.
|
|
|
|
|
pub const LATEST_VERSION: u32 = 1;
|
|
|
|
|
|
|
|
|
|
/// The Sprout configuration format.
|
2025-10-04 23:12:01 -07:00
|
|
|
#[derive(Serialize, Deserialize, Default, Clone)]
|
2025-10-01 18:25:49 -07:00
|
|
|
pub struct RootConfiguration {
|
2025-10-19 20:23:55 -07:00
|
|
|
/// The version of the configuration. This should always be declared
|
|
|
|
|
/// and be the latest version that is supported. If not specified, it is assumed
|
|
|
|
|
/// the configuration is the latest version.
|
2025-10-05 00:09:53 -07:00
|
|
|
#[serde(default = "latest_version")]
|
2025-10-04 23:12:01 -07:00
|
|
|
pub version: u32,
|
2025-10-19 20:23:55 -07:00
|
|
|
/// Values to be inserted into the root sprout context.
|
2025-10-01 18:25:49 -07:00
|
|
|
#[serde(default)]
|
2025-10-04 23:12:01 -07:00
|
|
|
pub values: BTreeMap<String, String>,
|
2025-10-19 20:23:55 -07:00
|
|
|
/// Drivers to load.
|
|
|
|
|
/// These drivers provide extra functionality like filesystem support to Sprout.
|
|
|
|
|
/// Each driver has a name which uniquely identifies it inside Sprout.
|
2025-10-04 23:12:01 -07:00
|
|
|
#[serde(default)]
|
2025-10-12 22:39:56 -07:00
|
|
|
pub drivers: BTreeMap<String, DriverDeclaration>,
|
2025-10-19 20:23:55 -07:00
|
|
|
/// Declares the extractors that add values to the sprout context that are calculated
|
|
|
|
|
/// at runtime. Each extractor has a name which corresponds to the value it will set
|
|
|
|
|
/// inside the sprout context.
|
2025-10-12 22:39:56 -07:00
|
|
|
#[serde(default)]
|
2025-10-13 00:55:11 -07:00
|
|
|
pub extractors: BTreeMap<String, ExtractorDeclaration>,
|
|
|
|
|
#[serde(default)]
|
2025-10-04 23:12:01 -07:00
|
|
|
pub actions: BTreeMap<String, ActionDeclaration>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub entries: BTreeMap<String, EntryDeclaration>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub generators: BTreeMap<String, GeneratorDeclaration>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub phases: PhasesConfiguration,
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-19 20:23:55 -07:00
|
|
|
fn latest_version() -> u32 {
|
|
|
|
|
LATEST_VERSION
|
2025-10-01 18:25:49 -07:00
|
|
|
}
|