Add Layer::process_command

This commit is contained in:
Hanno Braun 2024-10-23 18:50:48 +02:00
parent c16fbfe33e
commit 8813c8324b

View File

@ -23,6 +23,24 @@ impl<S> Layer<S> {
Self { state }
}
/// # Process a command without capturing any events
///
/// The command is processed synchronously. When this method returns, the
/// state has been updated.
pub fn process_command<C>(&mut self, command: C) -> C::Result
where
C: Command<S>,
{
let mut events = Vec::new();
let result = command.decide(&self.state, &mut events);
for event in events {
event.evolve(&mut self.state);
}
result
}
/// # Process a command and capture the events that produces
///
/// The command is processed synchronously. When this method returns, the