Skip to main content

Simulation

Trait Simulation 

Source
pub trait Simulation: SimulationState {
    type LoadData;
    type StateLoadingError;

    // Required methods
    fn reload(
        &mut self,
        data: Self::LoadData,
    ) -> Result<(), Self::StateLoadingError>;
    unsafe fn call(&mut self, event: Self::Event);
    unsafe fn revert(&mut self, event: Self::Event);

    // Provided methods
    fn try_call(&mut self, event: Self::Event) -> bool { ... }
    fn try_revert(&mut self, event: Self::Event) -> bool { ... }
    fn prepare_call(&mut self) -> CallState<'_, Self, Call> { ... }
    fn prepare_revert(&mut self) -> CallState<'_, Self, Revert> { ... }
}
Expand description

The Simulation trait extends SimulationState by providing mutable access to modify the simulation state via events.

Required Associated Types§

Source

type LoadData

The type of data used to load the simulation state.

Source

type StateLoadingError

The error type returned when loading the simulation state fails.

Required Methods§

Source

fn reload( &mut self, data: Self::LoadData, ) -> Result<(), Self::StateLoadingError>

Reloads the simulation state from the provided data.

Source

unsafe fn call(&mut self, event: Self::Event)

Calls the provided event.

§Safety

The caller must ensure that the event is valid and can be called in the current simulation state.

Source

unsafe fn revert(&mut self, event: Self::Event)

Reverts the provided event.

§Safety

The caller must ensure that the event is valid and can be reverted in the current simulation state.

Provided Methods§

Source

fn try_call(&mut self, event: Self::Event) -> bool

Tries to call the provided event and returns if it was successful.

Source

fn try_revert(&mut self, event: Self::Event) -> bool

Tries to revert the provided event and returns if it was successful.

Source

fn prepare_call(&mut self) -> CallState<'_, Self, Call>

Prepares a safe helper to list callable elements and choose one to call.

Source

fn prepare_revert(&mut self) -> CallState<'_, Self, Revert>

Prepares a safe helper to list revertable elements and choose one to revert.

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§