pub trait OptionDiffDomain {
type Domain: Domain<State = Self::State, Diff = Option<Self::State>>;
type State: Clone;
// Provided methods
fn get_cur_state(
state_diff: StateDiffRef<'_, Self::Domain>,
) -> &<<Self as OptionDiffDomain>::Domain as Domain>::State { ... }
fn get_cur_state_mut(
state_diff: StateDiffRefMut<'_, Self::Domain>,
) -> &mut <<Self as OptionDiffDomain>::Domain as Domain>::State { ... }
}Expand description
In case your domain has a Diff that is an Option of its State, provides helper functions to retrieve the state in your tasks.
The functions get_cur_state and get_cur_state_mut
are available when read-only, respectively read-write, access is required.
In that case, just use the trait in your task files: use npc_engine_utils::OptionDiffDomain;.
Required Associated Types§
Provided Methods§
Sourcefn get_cur_state(
state_diff: StateDiffRef<'_, Self::Domain>,
) -> &<<Self as OptionDiffDomain>::Domain as Domain>::State
fn get_cur_state( state_diff: StateDiffRef<'_, Self::Domain>, ) -> &<<Self as OptionDiffDomain>::Domain as Domain>::State
Returns either the diff if it is not None, or the initial_state.
Sourcefn get_cur_state_mut(
state_diff: StateDiffRefMut<'_, Self::Domain>,
) -> &mut <<Self as OptionDiffDomain>::Domain as Domain>::State
fn get_cur_state_mut( state_diff: StateDiffRefMut<'_, Self::Domain>, ) -> &mut <<Self as OptionDiffDomain>::Domain as Domain>::State
Returns either the diff if it is not None, or copies the initial_state into the diff and returns it.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".