Skip to main content

YamlConfigurable

Trait YamlConfigurable 

Source
pub trait YamlConfigurable: Sized {
    // Required methods
    fn from_yaml(spec: &ExperimentSpec) -> Result<Self, ConfigError>;
    fn validate_against_emc(&self, emc: &EquationModelCard) -> ValidationResult;
    fn parameters(&self) -> HashMap<String, f64>;
}
Expand description

YAML configuration trait for EDD simulations.

Allows simulations to be configured from declarative YAML experiment specifications without custom code.

§Example

impl YamlConfigurable for HarmonicOscillator {
    fn from_yaml(spec: &ExperimentSpec) -> Result<Self, ConfigError> {
        let omega = spec.parameter("omega")
            .ok_or_else(|| ConfigError::field_error("omega", "required"))?;
        Ok(Self::new(omega))
    }

    fn validate_against_emc(&self, emc: &EquationModelCard) -> ValidationResult {
        // Check parameters are within EMC domain of validity
    }
}

Required Methods§

Source

fn from_yaml(spec: &ExperimentSpec) -> Result<Self, ConfigError>

Create simulation from YAML experiment specification.

§Arguments
  • spec - The experiment specification from YAML
§Errors

Returns ConfigError if the specification is invalid or missing required parameters.

Source

fn validate_against_emc(&self, emc: &EquationModelCard) -> ValidationResult

Validate configuration against EMC domain of validity.

Checks that all parameters fall within the valid ranges specified in the Equation Model Card.

Source

fn parameters(&self) -> HashMap<String, f64>

Extract parameters as a hashmap for evaluation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§