#[derive(Action)]
{
// Attributes available to this derive:
#[action]
}
Expand description
Derive macro for the Action trait
Generates a name() method that returns the variant name as a static string.
With #[action(infer_categories)], also generates:
category() -> Option<&'static str>- Get action’s categorycategory_enum() -> {Name}Category- Get category as enumis_{category}()predicates for each category{Name}Categoryenum with all discovered categories
With #[action(generate_dispatcher)], also generates:
{Name}Dispatchertrait with category-based dispatch methods
§Example
ⓘ
#[derive(Action, Clone, Debug)]
#[action(infer_categories, generate_dispatcher)]
enum MyAction {
SearchStart,
SearchClear,
ConnectionFormOpen,
ConnectionFormSubmit,
DidConnect,
Tick, // uncategorized
}
let action = MyAction::SearchStart;
assert_eq!(action.name(), "SearchStart");
assert_eq!(action.category(), Some("search"));
assert!(action.is_search());