Macro macro_machines::def_machine_debug [] [src]

macro_rules! def_machine_debug {
    ( machine $machine:ident
      $(<$(
        $type_var:ident $(: { $($type_constraint:path),+ })*
      ),+>)*
    {
      STATES [
        $(state $state:ident (
          $($data_name:ident : $data_type:ty $(= $data_default:expr)*),*
        ))+
      ]
      EVENTS [
        $(event $event:ident <$source:tt> $(=> <$target:ident>)*
          ($($param_name:ident : $param_type:ty $(= $param_default:expr)*),*)
          $({ $($state_data:ident),* } => $action:block)*
        )+
      ]
      EXTENDED [
        $($ext_name:ident : $ext_type:ty $(= $ext_default:expr)*),*
      ]
      $(self_reference: $self_reference:ident)*
      initial_state: $initial:ident $({
        $(initial_action: $initial_action:block)*
      })*
      $(terminal_state: $terminal:ident $({
        $(terminate_success: $terminate_success:block)*
        $(terminate_failure: $terminate_failure:block)*
      })*)*
    }

  ) => { ... };
    ( $machine:ident
    $(<$(
      $type_var:ident $(: { $($type_constraint:path),+ })*
    ),+>)*
    $(($(
      $ext_name:ident : $ext_type:ty $(= $ext_default:expr)*
    ),*))*
    $(@ $self_reference:ident)*
    {
      STATES [
        $(state $state:ident (
          $($data_name:ident : $data_type:ty $(= $data_default:expr)*),*
        ))+
      ]
      EVENTS [
        $(event $event:ident <$source:tt> $(=> <$target:ident>)*
          ($($param_name:ident : $param_type:ty $(= $param_default:expr)*),*)
          $({ $($state_data:ident),* } => $action:block)*
        )+
      ]
      initial_state: $initial:ident $({
        $(initial_action: $initial_action:block)*
      })*
      $(terminal_state: $terminal:ident $({
        $(terminate_success: $terminate_success:block)*
        $(terminate_failure: $terminate_failure:block)*
      })*)*
    }

  ) => { ... };
    ( @impl_fn_handle_event
    machine $machine:ident {
      STATES [
        $(state $state:ident (
          $($data_name:ident : $data_type:ty $(= $data_default:expr)*),*
        ))+
      ]
      EVENTS [
        $(event $event:ident <$source:tt> $(=> <$target:ident>)*
          ($($param_name:ident),*)
          $({ $($state_data:ident),* } => $action:block)*
        )+
      ]
      EXTENDED [
        $($ext_name:ident : $ext_type:ty $(= $ext_default:expr)*),*
      ]
      $(self_reference: $self_reference:ident)*
    }

  ) => { ... };
    ( @event_internal_state_pattern
    $source:ident { $($state_data:ident),* }
  ) => { ... };
    ( @event_internal_state_pattern
    * { $($state_data:ident),* }
  ) => { ... };
    ( @event_action_external
    event $event:ident <$source:ident> => <$target:ident> $($action:block)*
  ) => { ... };
    ( @event_action_external
    event $event:ident <$source:tt> $($action:block)*
  ) => { ... };
    ( @event_action_external
    event $event:ident <*> => <$target:ident> $($action:block)*
  ) => { ... };
    ( @event_action_universal
    event $event:ident <*> => <$target:ident> $($action:block)*
  ) => { ... };
    ( @event_action_universal
    event $event:ident <$source:ident> $(=> <$target:ident>)* $($action:block)*
  ) => { ... };
    ( @event_action_internal
    event $event:ident <$source:ident> $($action:block)*
  ) => { ... };
    ( @event_action_internal
    event $event:ident <$source:tt> => <$target:ident> $($action:block)*
  ) => { ... };
    ( @event_transition <$source:ident> => <$target:ident> ) => { ... };
    ( @event_transition <$source:ident> ) => { ... };
    ( @event_transition <*> => <$target:ident> ) => { ... };
    ( @expr_default $default:expr ) => { ... };
    ( @expr_default ) => { ... };
    ( @expr_option $default:expr ) => { ... };
    ( @expr_option ) => { ... };
    ( @base
    machine $machine:ident
      $(<$(
        $type_var:ident $(: { $($type_constraint:path),+ })*
      ),+>)*
    {
      STATES [
        $(state $state:ident (
          $($data_name:ident : $data_type:ty $(= $data_default:expr)*),*
        ))+
      ]
      EVENTS [
        $(event $event:ident <$source:tt> $(=> <$target:ident>)*
          ($($param_name:ident : $param_type:ty $(= $param_default:expr)*),*)
          $({ $($state_data:ident),* } => $action:block)*
        )+
      ]
      EXTENDED [
        $($ext_name:ident : $ext_type:ty $(= $ext_default:expr)*),*
      ]
      $(self_reference: $self_reference:ident)*
      initial_state: $initial:ident $({
        $(initial_action: $initial_action:block)*
      })*
      $(terminal_state: $terminal:ident $({
        $(terminate_success: $terminate_success:block)*
        $(terminate_failure: $terminate_failure:block)*
      })*)*
    }

  ) => { ... };
}

State machines with a default initial state and deriving Debug.

For each extended state field, either the type must implement Default, or else a default expression is provided following =.

For a state machine that requires runtime initialization, see def_machine_nodefault_debug!.