Skip to main content

DemoEngine

Trait DemoEngine 

Source
pub trait DemoEngine: Sized + Clone {
    type Config: DeserializeOwned + Debug;
    type State: Clone + Serialize + DeserializeOwned + PartialEq + Debug;
    type StepResult: Debug;

Show 19 methods // Required methods fn from_yaml(yaml: &str) -> Result<Self, DemoError>; fn from_config(config: Self::Config) -> Self; fn config(&self) -> &Self::Config; fn reset(&mut self); fn reset_with_seed(&mut self, seed: u64); fn step(&mut self) -> Self::StepResult; fn is_complete(&self) -> bool; fn state(&self) -> Self::State; fn restore(&mut self, state: &Self::State); fn step_count(&self) -> u64; fn seed(&self) -> u64; fn meta(&self) -> &DemoMeta; fn falsification_criteria(&self) -> Vec<FalsificationCriterion>; fn evaluate_criteria(&self) -> Vec<CriterionResult>; fn metamorphic_relations(&self) -> Vec<MetamorphicRelation>; fn verify_mr(&self, mr: &MetamorphicRelation) -> MrResult; // Provided methods fn run(&mut self, n: usize) -> Vec<Self::StepResult> { ... } fn is_verified(&self) -> bool { ... } fn verify_all_mrs(&self) -> Vec<MrResult> { ... }
}
Expand description

MANDATORY trait for ALL demos (EDD-compliant).

Per specification SIMULAR-DEMO-001, all demos must implement this trait to ensure:

  • YAML-first configuration
  • Deterministic replay
  • Renderer independence
  • Falsification support
  • Metamorphic testing

§Example

impl DemoEngine for TspEngine {
    type Config = TspConfig;
    type State = TspState;
    type StepResult = TspStepResult;

    fn from_yaml(yaml: &str) -> Result<Self, DemoError> {
        let config: TspConfig = serde_yaml::from_str(yaml)?;
        Ok(Self::from_config(config))
    }
    // ... other methods
}

Required Associated Types§

Source

type Config: DeserializeOwned + Debug

Configuration type loaded from YAML.

Source

type State: Clone + Serialize + DeserializeOwned + PartialEq + Debug

State snapshot for replay/audit.

Source

type StepResult: Debug

Result of a single step.

Required Methods§

Source

fn from_yaml(yaml: &str) -> Result<Self, DemoError>

Create engine from YAML configuration string.

§Errors

Returns DemoError::YamlParse if YAML is invalid. Returns DemoError::Validation if config fails validation.

Source

fn from_config(config: Self::Config) -> Self

Create engine from config struct.

Source

fn config(&self) -> &Self::Config

Get the current configuration.

Source

fn reset(&mut self)

Reset to initial state (same seed = same result).

Source

fn reset_with_seed(&mut self, seed: u64)

Reset with a new seed.

Source

fn step(&mut self) -> Self::StepResult

Execute one step (deterministic given state + seed).

Source

fn is_complete(&self) -> bool

Check if simulation is complete/converged.

Source

fn state(&self) -> Self::State

Get current state snapshot (for replay verification).

Source

fn restore(&mut self, state: &Self::State)

Restore from a state snapshot.

Source

fn step_count(&self) -> u64

Get current step number.

Source

fn seed(&self) -> u64

Get seed for reproducibility.

Source

fn meta(&self) -> &DemoMeta

Get demo metadata.

Source

fn falsification_criteria(&self) -> Vec<FalsificationCriterion>

Get falsification criteria from config.

Source

fn evaluate_criteria(&self) -> Vec<CriterionResult>

Evaluate all criteria against current state.

Source

fn metamorphic_relations(&self) -> Vec<MetamorphicRelation>

Get metamorphic relations for this demo.

Source

fn verify_mr(&self, mr: &MetamorphicRelation) -> MrResult

Verify a specific metamorphic relation.

Provided Methods§

Source

fn run(&mut self, n: usize) -> Vec<Self::StepResult>

Execute N steps.

Source

fn is_verified(&self) -> bool

Check if all criteria pass.

Source

fn verify_all_mrs(&self) -> Vec<MrResult>

Verify all metamorphic relations.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§