2025-10-11 14:35:29 -07:00
|
|
|
use crate::context::SproutContext;
|
2025-10-24 16:32:48 -07:00
|
|
|
use crate::entries::BootableEntry;
|
2025-11-03 02:04:21 -05:00
|
|
|
use alloc::rc::Rc;
|
|
|
|
|
use alloc::vec::Vec;
|
2025-10-11 14:35:29 -07:00
|
|
|
use anyhow::Result;
|
|
|
|
|
use anyhow::bail;
|
2025-11-02 23:28:31 -05:00
|
|
|
use edera_sprout_config::generators::GeneratorDeclaration;
|
2025-10-04 23:12:01 -07:00
|
|
|
|
2025-11-02 23:28:31 -05:00
|
|
|
/// The BLS generator.
|
2025-10-13 01:54:03 -07:00
|
|
|
pub mod bls;
|
2025-11-02 23:28:31 -05:00
|
|
|
|
|
|
|
|
/// The list generator.
|
2025-10-27 15:41:29 -04:00
|
|
|
pub mod list;
|
2025-10-04 23:12:01 -07:00
|
|
|
|
2025-11-02 23:28:31 -05:00
|
|
|
/// The matrix generator.
|
|
|
|
|
pub mod matrix;
|
2025-10-11 14:11:31 -07:00
|
|
|
|
2025-10-19 21:44:05 -07:00
|
|
|
/// 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.
|
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-24 16:32:48 -07:00
|
|
|
) -> Result<Vec<BootableEntry>> {
|
2025-10-04 23:12:01 -07:00
|
|
|
if let Some(matrix) = &generator.matrix {
|
|
|
|
|
matrix::generate(context, matrix)
|
2025-10-13 01:54:03 -07:00
|
|
|
} else if let Some(bls) = &generator.bls {
|
|
|
|
|
bls::generate(context, bls)
|
2025-10-27 15:41:29 -04:00
|
|
|
} else if let Some(list) = &generator.list {
|
|
|
|
|
list::generate(context, list)
|
2025-10-04 23:12:01 -07:00
|
|
|
} else {
|
2025-10-13 00:55:11 -07:00
|
|
|
bail!("unknown generator configuration");
|
2025-10-04 23:12:01 -07:00
|
|
|
}
|
|
|
|
|
}
|