scamper/history
Transition history recording and querying for scamper FSMs.
Types
A record of a single state transition.
pub type TransitionRecord(state, event, context) {
TransitionRecord(
from: state,
event: event,
to: state,
timestamp: Int,
context_snapshot: option.Option(context),
)
}
Constructors
-
TransitionRecord( from: state, event: event, to: state, timestamp: Int, context_snapshot: option.Option(context), )
Values
pub fn append(
history: List(TransitionRecord(state, event, context)),
record: TransitionRecord(state, event, context),
limit: option.Option(Int),
) -> List(TransitionRecord(state, event, context))
Append a record to the history (newest first). Trims to the limit during append if a limit is set.
pub fn filter_by_event(
history: List(TransitionRecord(state, event, context)),
event: event,
) -> List(TransitionRecord(state, event, context))
Filter history records by the event.
pub fn filter_by_from(
history: List(TransitionRecord(state, event, context)),
from: state,
) -> List(TransitionRecord(state, event, context))
Filter history records by the source state.
pub fn filter_by_to(
history: List(TransitionRecord(state, event, context)),
to: state,
) -> List(TransitionRecord(state, event, context))
Filter history records by the destination state.
pub fn last_n(
history: List(TransitionRecord(state, event, context)),
n: Int,
) -> List(TransitionRecord(state, event, context))
Get the last n records from history (newest first).
pub fn new_record(
from from: state,
event event: event,
to to: state,
timestamp timestamp: Int,
context_snapshot context_snapshot: option.Option(context),
) -> TransitionRecord(state, event, context)
Create a new transition record.