Trait Command

Source
pub trait Command<S> {
    type Result;
    type Event: Event<S>;

    // Required method
    fn decide(self, state: &S, events: &mut Vec<Self::Event>) -> Self::Result;
}
Expand description

A command that encodes a request to update a layer’s state

Required Associated Types§

Source

type Result

The direct result of processing a command that is returned to the caller

Changes to the state that result from a command are encoded as events (see Command::Event). In addition to that, a command may return information to the caller, and Result defines the type of that information.

Source

type Event: Event<S>

An event that encodes a change to the state

Events are produced by Command::decide and processed by Event::evolve.

Required Methods§

Source

fn decide(self, state: &S, events: &mut Vec<Self::Event>) -> Self::Result

Decide which events to produce, given the command and provided state

If the command must result in changes to the state, any number of events that describe these state changes can be produced.

Implementors§