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
28
29
30
use necsim_core::cogs::{MathsCore, RngCore};
use necsim_partitioning_core::partition::PartitionSize;

use crate::args::{config::rng::Rng, utils::parse::try_parse_state};

use super::super::BufferingSimulateArgsBuilder;

#[allow(dead_code)]
pub(in super::super) fn parse_and_normalise<M: MathsCore, G: RngCore<M>>(
    ron_args: &str,
    normalised_args: &mut BufferingSimulateArgsBuilder,
    mut logical_partition_size: PartitionSize,
) -> anyhow::Result<Rng<M, G>> {
    let SimulateArgsRngOnly { rng } =
        try_parse_state("simulate", ron_args, &mut logical_partition_size)?;

    normalised_args.rng(&rng);

    Ok(rng)
}

#[derive(DeserializeState)]
#[serde(bound = "")]
#[serde(rename = "Simulate")]
#[serde(deserialize_state = "PartitionSize")]
struct SimulateArgsRngOnly<M: MathsCore, G: RngCore<M>> {
    #[serde(alias = "randomness")]
    #[serde(deserialize_state)]
    rng: Rng<M, G>,
}