Trait aper::StateMachine

source ·
pub trait StateMachine: Clone + DeserializeOwned + Serialize + Debug + 'static {
    type Transition: Debug + Serialize + DeserializeOwned + Clone + PartialEq;
    type Conflict: Debug + Serialize + DeserializeOwned + Clone + PartialEq;

    // Required method
    fn apply(
        &self,
        transition: &Self::Transition
    ) -> Result<Self, Self::Conflict>;
}
Expand description

This trait provides the methods that Aper needs to be able to interact with an object as a state machine.

None of the methods in this trait provide access to the internal data of the state machine. It’s up to you to implement accessor methods (or use public fields) in order to expose the data necessary to render your views.

Required Associated Types§

source

type Transition: Debug + Serialize + DeserializeOwned + Clone + PartialEq

The StateMachine::Transition type associates another type with this state machine as its transitions.

source

type Conflict: Debug + Serialize + DeserializeOwned + Clone + PartialEq

Required Methods§

source

fn apply(&self, transition: &Self::Transition) -> Result<Self, Self::Conflict>

Update the state machine according to the given [Transition]. This method must be deterministic: calling it on a clone of the state with a clone of the [Transition] must result in the same state, even at a different time and on a different machine. This is the requirement that allows Aper to keep the state in sync across multiple machines.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl StateMachine for Counter

§

type Transition = CounterTransition

§

type Conflict = NeverConflict

source§

impl<T> StateMachine for Atom<T>
where T: 'static + Serialize + DeserializeOwned + Clone + PartialEq + Debug + Copy,

source§

impl<T> StateMachine for Constant<T>
where T: 'static + Serialize + DeserializeOwned + Unpin + Send + Clone + PartialEq + Debug + Sync,

§

type Transition = InvalidTransition

§

type Conflict = NeverConflict

source§

impl<T: Debug + Clone + Serialize + DeserializeOwned + PartialEq + 'static> StateMachine for AtomRc<T>

§

type Transition = ReplaceAtomRc<T>

§

type Conflict = NeverConflict

source§

impl<T: Serialize + DeserializeOwned + Ord + PartialEq + Clone + Debug + 'static, V: StateMachine + PartialEq> StateMachine for Map<T, V>

§

type Transition = MapTransition<T, V>

§

type Conflict = NeverConflict

source§

impl<T: StateMachine + PartialEq> StateMachine for List<T>

§

type Transition = ListOperation<T>

§

type Conflict = ListConflict<T>