pub struct Session {
pub state: GameState,
pub log: Vec<Event>,
}Fields§
§state: GameState§log: Vec<Event>Implementations§
Source§impl Session
impl Session
Sourcepub fn from_events(
log: Vec<Event>,
observers: &mut [&mut dyn EventObserver],
) -> Session
pub fn from_events( log: Vec<Event>, observers: &mut [&mut dyn EventObserver], ) -> Session
Start a session from a log (a fresh [GameStarted] or a loaded save).
Observers see every event, replayed ones included, so derived consumers
(telemetry, traces) rebuild for free.
Sourcepub fn execute(
&mut self,
command: Command,
observers: &mut [&mut dyn EventObserver],
) -> Result<&[Event], CommandError>
pub fn execute( &mut self, command: Command, observers: &mut [&mut dyn EventObserver], ) -> Result<&[Event], CommandError>
Validate + produce events, append them, fold them, notify observers. Returns the slice of newly produced events for presentation.
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more