1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//! Action trait for type-safe state mutations
use Debug;
use Hash;
/// Marker trait for actions that can be dispatched to the store
///
/// Actions represent intents to change state. They should be:
/// - Clone: Actions may be logged, replayed, or sent to multiple handlers
/// - Debug: For debugging and logging
/// - Send + 'static: For async dispatch across threads
///
/// Use `#[derive(Action)]` from `tui-dispatch-macros` to auto-implement this trait.
/// Extension trait for actions with category support
///
/// This trait is auto-implemented when using `#[derive(Action)]` with
/// `#[action(infer_categories)]`. It provides methods to query an action's
/// category for routing and filtering.
///
/// # Example
///
/// ```ignore
/// use tui_dispatch::ActionCategory;
///
/// #[derive(Action, Clone, Debug)]
/// #[action(infer_categories)]
/// enum MyAction {
/// SearchStart,
/// SearchClear,
/// ConnectionFormOpen,
/// }
///
/// let action = MyAction::SearchStart;
/// assert_eq!(action.category(), Some("search"));
/// assert!(matches!(action.category_enum(), MyActionCategory::Search));
/// ```
/// Trait for getting action parameters without the variant name.
///
/// Auto-implemented by `#[derive(Action)]`. Returns just the field values
/// as a string, suitable for display in action logs where the action name
/// is already shown separately.
///
/// # Example
///
/// ```ignore
/// #[derive(Action, Clone, Debug)]
/// enum MyAction {
/// SetFilter { query: String, limit: usize },
/// Tick,
/// }
///
/// let action = MyAction::SetFilter { query: "foo".into(), limit: 10 };
/// assert_eq!(action.name(), "SetFilter");
/// assert_eq!(action.params(), r#"{query: \"foo\", limit: 10}"#);
///
/// let tick = MyAction::Tick;
/// assert_eq!(tick.params(), "");
/// ```
/// Trait for actions that provide a summary representation for logging
///
/// The default implementation uses the Debug representation. Override
/// `summary()` to provide concise summaries for actions with large payloads
/// (e.g., showing byte counts instead of full data).
///
/// # Example
///
/// ```ignore
/// impl ActionSummary for MyAction {
/// fn summary(&self) -> String {
/// match self {
/// MyAction::DidLoadData { data } => {
/// format!("DidLoadData {{ bytes: {} }}", data.len())
/// }
/// _ => format!("{:?}", self)
/// }
/// }
/// }
/// ```