about summary refs log tree commit diff
path: root/finito-core/src/lib.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2018-12-13T12·39+0100
committerVincent Ambo <mail@tazj.in>2018-12-13T12·39+0100
commit183ee2accc06680be470911aa0d1f6744e3e9ba7 (patch)
treee0e189436e21ac9c2797321080ecfa15f9845863 /finito-core/src/lib.rs
parent1a90856ba45a26dccfd9e68d3a9b036d7ceeff82 (diff)
fix(core): Ensure FSM state can be created from backend state ref
The action interpreter can not own the backend state, hence it must be
possible to create the required state from a reference to the
backend's state.
Diffstat (limited to 'finito-core/src/lib.rs')
-rw-r--r--finito-core/src/lib.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/finito-core/src/lib.rs b/finito-core/src/lib.rs
index 0dda30ae9a52..517bfad2bc74 100644
--- a/finito-core/src/lib.rs
+++ b/finito-core/src/lib.rs
@@ -166,7 +166,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, Self::State) -> Result<Vec<Self::Event>, Self::Error>;
+    fn act(Self::Action, &Self::State) -> Result<Vec<Self::Event>, Self::Error>;
 }
 
 /// This function is the primary function used to advance a state
@@ -208,7 +208,7 @@ pub fn advance<S: FSM>(state: S, event: S::Event) -> (S, Vec<S::Action>) {
 /// state type which can be used to track application state that must
 /// be made available to action handlers, for example to pass along
 /// database connections.
-pub trait FSMBackend<S> {
+pub trait FSMBackend<S: 'static> {
     /// Key type used to identify individual state machines in this
     /// backend.
     ///
@@ -235,9 +235,9 @@ pub trait FSMBackend<S> {
     /// **Note**: Whether actions are automatically executed depends
     /// on the backend used. Please consult the backend's
     /// documentation for details.
-    fn advance<F: FSM>(&self, key: Self::Key, event: F::Event) -> Result<F, Self::Error>
+    fn advance<'a, F: FSM>(&'a self, key: Self::Key, event: F::Event) -> Result<F, Self::Error>
     where F: FSM + Serialize + DeserializeOwned,
-          F::State: From<S>,
+          F::State: From<&'a S>,
           F::Event: Serialize + DeserializeOwned,
           F::Action: Serialize + DeserializeOwned;
 }