Trait State

Source
pub trait State<OrderKey: Ord>: Clone {
    type Event: Clone + Event<OrderKey>;

    // Required method
    fn apply(&mut self, event: &Self::Event);
}
Expand description

A trait representing a state that can be modified by events.

The state must be clonable and can be updated based on the events it receives. Events must have an associated order key of type OrderKey to determine their sequence.

§Type Parameters

  • OrderKey: The type that determines the order of events, which must implement Ord.

Required Associated Types§

Source

type Event: Clone + Event<OrderKey>

The type of event that modifies the state.

Required Methods§

Source

fn apply(&mut self, event: &Self::Event)

Applies an event to the current state, modifying it accordingly.

§Arguments
  • event: The event that will be applied to the state.

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§