2025-10-11 14:11:31 -07:00
|
|
|
use crate::config::EntryDeclaration;
|
2025-10-11 14:35:29 -07:00
|
|
|
use crate::context::SproutContext;
|
2025-10-11 14:11:31 -07:00
|
|
|
use crate::generators::matrix::MatrixConfiguration;
|
2025-10-11 14:35:29 -07:00
|
|
|
use anyhow::Result;
|
|
|
|
|
use anyhow::bail;
|
2025-10-11 14:11:31 -07:00
|
|
|
use serde::{Deserialize, Serialize};
|
2025-10-04 23:12:01 -07:00
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
|
|
|
|
pub mod matrix;
|
|
|
|
|
|
2025-10-11 14:11:31 -07:00
|
|
|
#[derive(Serialize, Deserialize, Default, Clone)]
|
|
|
|
|
pub struct GeneratorDeclaration {
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub matrix: Option<MatrixConfiguration>,
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-04 23:12:01 -07:00
|
|
|
pub fn generate(
|
2025-10-11 14:35:29 -07:00
|
|
|
context: Rc<SproutContext>,
|
2025-10-04 23:12:01 -07:00
|
|
|
generator: &GeneratorDeclaration,
|
2025-10-11 14:35:29 -07:00
|
|
|
) -> Result<Vec<(Rc<SproutContext>, EntryDeclaration)>> {
|
2025-10-04 23:12:01 -07:00
|
|
|
if let Some(matrix) = &generator.matrix {
|
|
|
|
|
matrix::generate(context, matrix)
|
|
|
|
|
} else {
|
2025-10-13 00:55:11 -07:00
|
|
|
bail!("unknown generator configuration");
|
2025-10-04 23:12:01 -07:00
|
|
|
}
|
|
|
|
|
}
|