1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use serde::Deserialize;

use necsim_core_bond::OpenClosedUnitF64 as PositiveUnitF64;

use crate::args::utils::parse::try_parse;

use super::super::BufferingSimulateArgsBuilder;

pub(in super::super) fn parse_and_normalise(
    ron_args: &str,
    normalised_args: &mut BufferingSimulateArgsBuilder,
) -> anyhow::Result<PositiveUnitF64> {
    let SimulateArgsSpeciationOnly {
        speciation_probability_per_generation,
    } = try_parse("simulate", ron_args)?;

    normalised_args.speciation(&speciation_probability_per_generation);

    Ok(speciation_probability_per_generation)
}

#[derive(Deserialize)]
#[serde(rename = "Simulate")]
struct SimulateArgsSpeciationOnly {
    #[serde(alias = "speciation")]
    speciation_probability_per_generation: PositiveUnitF64,
}