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§
Sourcetype Config: DeserializeOwned + Debug
type Config: DeserializeOwned + Debug
Configuration type loaded from YAML.
Sourcetype State: Clone + Serialize + DeserializeOwned + PartialEq + Debug
type State: Clone + Serialize + DeserializeOwned + PartialEq + Debug
State snapshot for replay/audit.
Sourcetype StepResult: Debug
type StepResult: Debug
Result of a single step.
Required Methods§
Sourcefn from_yaml(yaml: &str) -> Result<Self, DemoError>
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.
Sourcefn from_config(config: Self::Config) -> Self
fn from_config(config: Self::Config) -> Self
Create engine from config struct.
Sourcefn reset_with_seed(&mut self, seed: u64)
fn reset_with_seed(&mut self, seed: u64)
Reset with a new seed.
Sourcefn step(&mut self) -> Self::StepResult
fn step(&mut self) -> Self::StepResult
Execute one step (deterministic given state + seed).
Sourcefn is_complete(&self) -> bool
fn is_complete(&self) -> bool
Check if simulation is complete/converged.
Sourcefn step_count(&self) -> u64
fn step_count(&self) -> u64
Get current step number.
Sourcefn falsification_criteria(&self) -> Vec<FalsificationCriterion>
fn falsification_criteria(&self) -> Vec<FalsificationCriterion>
Get falsification criteria from config.
Sourcefn evaluate_criteria(&self) -> Vec<CriterionResult>
fn evaluate_criteria(&self) -> Vec<CriterionResult>
Evaluate all criteria against current state.
Sourcefn metamorphic_relations(&self) -> Vec<MetamorphicRelation>
fn metamorphic_relations(&self) -> Vec<MetamorphicRelation>
Get metamorphic relations for this demo.
Sourcefn verify_mr(&self, mr: &MetamorphicRelation) -> MrResult
fn verify_mr(&self, mr: &MetamorphicRelation) -> MrResult
Verify a specific metamorphic relation.
Provided Methods§
Sourcefn run(&mut self, n: usize) -> Vec<Self::StepResult>
fn run(&mut self, n: usize) -> Vec<Self::StepResult>
Execute N steps.
Sourcefn is_verified(&self) -> bool
fn is_verified(&self) -> bool
Check if all criteria pass.
Sourcefn verify_all_mrs(&self) -> Vec<MrResult>
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", so this trait is not object safe.