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
//! The action enum that every menu's `update` returns.
//!
//! Per the consumer-owned-traits standard, menus expose a single narrow port
//! (`update -> MenuAction`) that the caller matches on. There is intentionally
//! no `Result` here — menus are total. "Nothing happened" is represented by
//! [`MenuAction::None`], not by an `Err`.
/// What a menu did in response to a key event.
///
/// Constructed by [`crate::application::menu::*::update`] methods and matched
/// on by the caller. The variants are deliberately flat — no nested state —
/// because callers should be able to handle each case with a single arm.
///
/// # Examples
///
/// ```rust
/// use cornichon::domain::MenuAction;
///
/// fn handle(action: MenuAction) {
/// match action {
/// MenuAction::None => {}
/// MenuAction::Selected(item) => println!("chose: {}", item.name),
/// MenuAction::Cancelled => println!("aborted"),
/// MenuAction::Activated => println!("activated (no selection)"),
/// }
/// }
/// ```