impl_state

Attribute Macro impl_state 

Source
#[impl_state]
Expand description

Modifies the methods in an impl block to work with the type-state pattern.

Usage: #[impl_state]

What it does:

  • Applies type-state-specific transformations to methods in an impl block,
  • Enforces state requirements on methods with the #[require] macro,
  • Transforms methods that transition between states using the #[switch_to] macro,
  • Automatically adds the hidden _state field to the Self {} struct initialization, ensuring compliance with the type-state pattern.

Also:

  • Consumes the #[require] and #[switch_to] macros and handles the necessary transformations for those macros,
  • Ensures that the methods only execute in the correct state and can safely transition between valid states.