// apply a message to cause a state transition. Returns false if the state
// transition is invalid.
apply a message to cause a state transition. Returns false if the state
transition is invalid.
// apply a message to cause a state transition . Returns false if the state // transition is invalid .
func apply(cur *State, m *Message) (*State, bool) {
	for _, trans := range Rules {
		if trans.Event == m.Code && trans.From == cur.Code {
			metafora.Debugf("Transitioned %s", trans)
			if m.Err != nil {
				cur.Errors = append(cur.Errors, NewErr(m.Err, time.Now()))
			}
			return &State{Code: trans.To, Until: m.Until, Errors: cur.Errors}, true
		}
	}
	return cur, false
}
func apply ( cur * State , m * Message ) ( * State , bool ) { for _ , trans := range Rules { if trans . Event == m . Code && trans . From == cur . Code { metafora . Debugf ( " " , trans ) if m . Err != nil { cur . Errors = append ( cur . Errors , NewErr ( m . Err , time . Now ( ) ) ) } return & State { Code : trans . To , Until : m . Until , Errors : cur . Errors } , true } } return cur , false }
apply a message to cause a state transition.
apply a message to cause a state transition .
//XXX Is a linear scan of all rules really the best option here? // Append errors from message // New State + Message's Until + Combined Errors