fj_kernel/services/
objects.rs1use crate::objects::{Object, Objects, WithHandle};
2
3use super::State;
4
5impl State for Objects {
6 type Command = Operation;
7 type Event = InsertObject;
8
9 fn decide(&self, command: Self::Command, events: &mut Vec<Self::Event>) {
10 let Operation::InsertObject { object } = command;
11 events.push(InsertObject { object });
12 }
13
14 fn evolve(&mut self, event: &Self::Event) {
15 event.object.clone().insert(self);
16 }
17}
18
19#[derive(Debug)]
21pub enum Operation {
22 InsertObject {
27 object: Object<WithHandle>,
29 },
30}
31
32#[derive(Clone, Debug)]
34pub struct InsertObject {
35 pub object: Object<WithHandle>,
37}