diff options
| -rw-r--r-- | talpid-core/src/tunnel_state_machine/mod.rs | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/talpid-core/src/tunnel_state_machine/mod.rs b/talpid-core/src/tunnel_state_machine/mod.rs index f37a035ce0..3338d3c4cc 100644 --- a/talpid-core/src/tunnel_state_machine/mod.rs +++ b/talpid-core/src/tunnel_state_machine/mod.rs @@ -294,6 +294,21 @@ macro_rules! state_wrapper { $wrapper_name::$state_variant(state) } })* + + impl $wrapper_name { + fn handle_event( + self, + commands: &mut mpsc::UnboundedReceiver<TunnelCommand>, + shared_values: &mut SharedTunnelStateValues, + ) -> TunnelStateMachineAction { + match self { + $($wrapper_name::$state_variant(state) => { + let event_consequence = state.handle_event(commands, shared_values); + TunnelStateMachineAction::from(event_consequence) + })* + } + } + } } } @@ -306,32 +321,3 @@ state_wrapper! { Blocked(BlockedState), } } - -impl TunnelStateWrapper { - fn handle_event( - self, - commands: &mut mpsc::UnboundedReceiver<TunnelCommand>, - shared_values: &mut SharedTunnelStateValues, - ) -> TunnelStateMachineAction { - macro_rules! handle_event { - ( $($state:ident),* $(,)* ) => { - match self { - $( - TunnelStateWrapper::$state(state) => { - let event_consequence = state.handle_event(commands, shared_values); - TunnelStateMachineAction::from(event_consequence) - } - )* - } - } - } - - handle_event! { - Disconnected, - Connecting, - Connected, - Disconnecting, - Blocked, - } - } -} |
