mirror of
https://github.com/edera-dev/sprout.git
synced 2025-12-20 05:00:18 +00:00
chore(code): move crates/sprout to crates/boot and name it edera-sprout-boot
This commit is contained in:
34
crates/boot/src/generators.rs
Normal file
34
crates/boot/src/generators.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user