2025-10-11 14:35:29 -07:00
|
|
|
use crate::context::SproutContext;
|
2025-10-14 12:47:33 -07:00
|
|
|
use crate::entries::EntryDeclaration;
|
2025-10-13 01:54:03 -07:00
|
|
|
use crate::generators::bls::BlsConfiguration;
|
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;
|
|
|
|
|
|
2025-10-13 01:54:03 -07:00
|
|
|
pub mod bls;
|
2025-10-04 23:12:01 -07:00
|
|
|
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-13 01:54:03 -07:00
|
|
|
#[serde(default)]
|
|
|
|
|
pub bls: Option<BlsConfiguration>,
|
2025-10-11 14:11:31 -07:00
|
|
|
}
|
|
|
|
|
|
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)
|
2025-10-13 01:54:03 -07:00
|
|
|
} else if let Some(bls) = &generator.bls {
|
|
|
|
|
bls::generate(context, bls)
|
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
|
|
|
}
|
|
|
|
|
}
|