fn on_event_mut(
        &mut self,
        event: Self::Event,
    ) -> Result<Vec<Self::Command>, MachineError<Self::Error>>
    where
        Self: Clone,
    {
        // NOTE: This clone is actually nice in some sense, giving us a kind of transactionality.
        //   However if there are really big things in state it could be an issue.
        let res = self.clone().on_event(event);
        match res {
            TransitionResult::Ok {
                commands,
                new_state,
                shared_state,
            } => {
                *self = Self::from_parts(shared_state, new_state);
                Ok(commands)
            }
            TransitionResult::OkNoShare {
                commands,
                new_state,
            } => {
                self.set_state(new_state);
                Ok(commands)
            }
            TransitionResult::InvalidTransition => Err(MachineError::InvalidTransition),
            TransitionResult::Err(e) => Err(MachineError::Underlying(e)),
        }
    }
/// Handle an incoming event and mutate the state machine to update to the new state and apply
/// any changes to shared state.
///
/// Returns the commands issued by the transition on success, otherwise a [MachineError]
Handle an incoming event and mutate the state machine to update to the new state and apply
any changes to shared state.

Returns the commands issued by the transition on success, otherwise a [MachineError]
Handle an incoming event and mutate the state machine to update to the new state and apply any changes to shared state . Returns the commands issued by the transition on success otherwise a [ MachineError ]
fn on_event_mut(
        &mut self,
        event: Self::Event,
    ) -> Result<Vec<Self::Command>, MachineError<Self::Error>>
    where
        Self: Clone,
    {
        // NOTE: This clone is actually nice in some sense, giving us a kind of transactionality.
        //   However if there are really big things in state it could be an issue.
        let res = self.clone().on_event(event);
        match res {
            TransitionResult::Ok {
                commands,
                new_state,
                shared_state,
            } => {
                *self = Self::from_parts(shared_state, new_state);
                Ok(commands)
            }
            TransitionResult::OkNoShare {
                commands,
                new_state,
            } => {
                self.set_state(new_state);
                Ok(commands)
            }
            TransitionResult::InvalidTransition => Err(MachineError::InvalidTransition),
            TransitionResult::Err(e) => Err(MachineError::Underlying(e)),
        }
    }
fn on_event_mut ( & mut self , event : Self :: Event , ) -> Result < Vec < Self :: Command > , MachineError < Self :: Error > > where Self : Clone , { // NOTE: This clone is actually nice in some sense, giving us a kind of transactionality. //   However if there are really big things in state it could be an issue. let res = self . clone ( ) . on_event ( event ) ; match res { TransitionResult :: Ok { commands , new_state , shared_state , } => { * self = Self :: from_parts ( shared_state , new_state ) ; Ok ( commands ) } TransitionResult :: OkNoShare { commands , new_state , } => { self . set_state ( new_state ) ; Ok ( commands ) } TransitionResult :: InvalidTransition => Err ( MachineError :: InvalidTransition ) , TransitionResult :: Err ( e ) => Err ( MachineError :: Underlying ( e ) ) , } }
Handle an incoming event and mutate the state machine to update to the new state and apply
any changes to shared state.
Handle an incoming event and mutate the state machine to update to the new state and apply any changes to shared state .
&mut self
event
Self::Event
&mut self
event
Self::Event