pub trait Stateful<CONTEXT, STATE> {
// Required methods
fn from_parts(context: CONTEXT, state: STATE) -> Self
where Self: Sized + 'static;
fn into_parts(self) -> (CONTEXT, STATE);
fn context(&self) -> &CONTEXT;
fn state(&self) -> &STATE;
fn state_mut(&mut self) -> &mut STATE;
// Provided method
fn configure<I1: Into<CONTEXT>, I2: Into<STATE>>(
context: I1,
initial_state: I2,
) -> Self
where Self: Sized + 'static { ... }
}Expand description
A shared interface of objects that provide access to
an immutable CONTEXT and mutable STATE.
Required Methods§
Sourcefn from_parts(context: CONTEXT, state: STATE) -> Selfwhere
Self: Sized + 'static,
fn from_parts(context: CONTEXT, state: STATE) -> Selfwhere
Self: Sized + 'static,
Create new Stateful instance from CONTEXT and STATE.
Sourcefn into_parts(self) -> (CONTEXT, STATE)
fn into_parts(self) -> (CONTEXT, STATE)
Destruct the Stateful instance into CONTEXT and STATE objects.
Sourcefn state_mut(&mut self) -> &mut STATE
fn state_mut(&mut self) -> &mut STATE
Access to the underlying STATE as a mutable reference.
Keep in mind that having a consistent state is important for the correctness
of Algorithm and GenAlgorithm. You should modify the internal state
of a Stateful object only in rare, well-defined situations.