pub trait Simulation {
type StateLoadingError;
type AccessData: ?Sized;
type LoadData;
type Event: Copy + Ord;
type EventContainer<'a>: Iterator<Item = Self::Event>
where Self: 'a;
// Required methods
fn data(&self) -> &Self::AccessData;
fn reload(
&mut self,
data: Self::LoadData,
) -> Result<(), Self::StateLoadingError>;
fn callables(&self) -> Self::EventContainer<'_>;
fn revertables(&self) -> Self::EventContainer<'_>;
fn callable(&self, event: Self::Event) -> bool;
fn revertable(&self, event: Self::Event) -> bool;
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 provides an interface for interacting with a simulation.
Required Associated Types§
Sourcetype StateLoadingError
type StateLoadingError
The error type returned when loading the simulation state fails.
Sourcetype AccessData: ?Sized
type AccessData: ?Sized
The type used to access the current state.
Sourcetype EventContainer<'a>: Iterator<Item = Self::Event>
where
Self: 'a
type EventContainer<'a>: Iterator<Item = Self::Event> where Self: 'a
The type of container used to access the available events.
Required Methods§
Sourcefn data(&self) -> &Self::AccessData
fn data(&self) -> &Self::AccessData
Returns a reference to the data which repsesents the current state.
Sourcefn reload(
&mut self,
data: Self::LoadData,
) -> Result<(), Self::StateLoadingError>
fn reload( &mut self, data: Self::LoadData, ) -> Result<(), Self::StateLoadingError>
Reloads the simulation state from the provided data.
Sourcefn callables(&self) -> Self::EventContainer<'_>
fn callables(&self) -> Self::EventContainer<'_>
Returns the events that can currently be called.
Sourcefn revertables(&self) -> Self::EventContainer<'_>
fn revertables(&self) -> Self::EventContainer<'_>
Returns the events that can currently be reverted.
Sourcefn revertable(&self, event: Self::Event) -> bool
fn revertable(&self, event: Self::Event) -> bool
Checks if the provided event can be reverted.
Provided Methods§
Sourcefn try_call(&mut self, event: Self::Event) -> bool
fn try_call(&mut self, event: Self::Event) -> bool
Tries to call the provided event and returns if it was successful.
Sourcefn try_revert(&mut self, event: Self::Event) -> bool
fn try_revert(&mut self, event: Self::Event) -> bool
Tries to revert the provided event and returns if it was successful.
Sourcefn prepare_call(&mut self) -> CallState<'_, Self, Call>
fn prepare_call(&mut self) -> CallState<'_, Self, Call>
Prepares a safe helper to list callable elements and choose one to call.
Sourcefn prepare_revert(&mut self) -> CallState<'_, Self, Revert>
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.