mirror of
https://github.com/edera-dev/sprout.git
synced 2025-12-19 21:20:17 +00:00
35 lines
959 B
Rust
35 lines
959 B
Rust
use crate::context::SproutContext;
|
|
use crate::entries::BootableEntry;
|
|
use alloc::rc::Rc;
|
|
use alloc::vec::Vec;
|
|
use anyhow::Result;
|
|
use anyhow::bail;
|
|
use edera_sprout_config::generators::GeneratorDeclaration;
|
|
|
|
/// The BLS generator.
|
|
pub mod bls;
|
|
|
|
/// The list generator.
|
|
pub mod list;
|
|
|
|
/// The matrix generator.
|
|
pub mod matrix;
|
|
|
|
/// Runs the generator specified by the `generator` option.
|
|
/// It uses the specified `context` as the parent context for
|
|
/// the generated entries, injecting more values if needed.
|
|
pub fn generate(
|
|
context: Rc<SproutContext>,
|
|
generator: &GeneratorDeclaration,
|
|
) -> Result<Vec<BootableEntry>> {
|
|
if let Some(matrix) = &generator.matrix {
|
|
matrix::generate(context, matrix)
|
|
} else if let Some(bls) = &generator.bls {
|
|
bls::generate(context, bls)
|
|
} else if let Some(list) = &generator.list {
|
|
list::generate(context, list)
|
|
} else {
|
|
bail!("unknown generator configuration");
|
|
}
|
|
}
|