diff options
author | Vincent Ambo <mail@tazj.in> | 2018-09-26T21·05+0200 |
---|---|---|
committer | Vincent Ambo <mail@tazj.in> | 2018-09-26T21·05+0200 |
commit | 37590ae0f61187f080fe5b09d037ad428b4b1db4 (patch) | |
tree | d83602b1e290183638d615bf3d187069edb5a2ec /finito-core/src/lib.rs | |
parent | 406a90e8d696835f4b68e35f60f585af710c49c8 (diff) |
feat(core): Add associated 'Error' type to FSM trait
Adds an associated 'Error' type that can be returned by actions when an interpretation fails.
Diffstat (limited to 'finito-core/src/lib.rs')
-rw-r--r-- | finito-core/src/lib.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/finito-core/src/lib.rs b/finito-core/src/lib.rs index 2f27a2bdf958..8770a239dd0e 100644 --- a/finito-core/src/lib.rs +++ b/finito-core/src/lib.rs @@ -108,6 +108,7 @@ //! //! Please reach out! I want to know why! +use std::fmt::Debug; use std::mem; /// Primary trait that needs to be implemented for every state type @@ -129,6 +130,10 @@ pub trait FSM where Self: Sized { /// actions that can occur in the state-machine. type Action; + /// The associated error type of an FSM represents failures that + /// can occur during action processing. + type Error: Debug; + /// `handle` deals with any incoming events to cause state /// transitions and emit actions. This function is the core logic /// of any state machine. @@ -152,7 +157,7 @@ pub trait FSM where Self: Sized { /// `act` interprets and executes FSM actions. This is the only /// part of an FSM in which side-effects are allowed. - fn act(Self::Action) -> Vec<Self::Event>; + fn act(Self::Action) -> Result<Vec<Self::Event>, Self::Error>; } /// This function is the primary function used to advance a state |