• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

veeso / tui-realm / 11315916088

13 Oct 2024 04:21PM UTC coverage: 92.774% (-0.3%) from 93.055%
11315916088

Pull #83

github

web-flow
Update README.md demo file link (#81)
Pull Request #83: 2.0

5 of 6 new or added lines in 2 files covered. (83.33%)

7 existing lines in 2 files now uncovered.

2799 of 3017 relevant lines covered (92.77%)

8.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/core/command.rs
1
//! ## Command
2
//!
3
//! This module exposes the Command type, which must be used when sending command to the `MockComponent` from the
4
//! `Component` after an `Event`.
5

6
use super::State;
7

8
// -- Command
9

10
/// A command defines the "abstract" operation to perform in front of an Event.
11
/// The command must be passed in the `on` method of the `Component`
12
/// when calling `perform` method of the `MockComponent`.
13
/// There is not a default conversion from `Event -> Cmd`, but it must be implmented by the user in the
14
/// `Component` in a match case.
15
#[derive(Debug, Eq, PartialEq, Copy, Clone, PartialOrd, Hash)]
×
16
pub enum Cmd {
17
    /// Describes a "user" typed a character
18
    Type(char),
×
19
    /// Describes a "cursor" movement, or a movement of another kind
20
    Move(Direction),
×
21
    /// An expansion of `Move` which defines the scroll. The step should be defined in props, if any.
22
    Scroll(Direction),
×
23
    /// Describes a movement with a position
24
    GoTo(Position),
×
25
    /// User submit field
26
    Submit,
27
    /// User "deleted" something
28
    Delete,
29
    /// User "cancelled" something; used to distinguish between Del and Canc
30
    Cancel,
31
    /// User toggled something
32
    Toggle,
33
    /// User changed something
34
    Change,
35
    /// A user defined amount of time has passed and the component should be updated
36
    Tick,
37
    /// A user defined command type. You won't find these kind of Command in the stdlib, but you can use them in your own components.
38
    Custom(&'static str),
×
39
    /// `None` won't do anything
40
    None,
41
}
42

43
/// Defines the 4 directions in front of a cursor movement.
44
/// This may be used after a `Arrow::Up` event or for example if you want something more geeky
45
/// when using `WASD`
46
#[derive(Debug, Eq, PartialEq, Copy, Clone, PartialOrd, Hash)]
×
47
pub enum Direction {
48
    Down,
49
    Left,
50
    Right,
51
    Up,
52
}
53

54
/// Describes position on movement
55
#[derive(Debug, Eq, PartialEq, Copy, Clone, PartialOrd, Hash)]
×
56
pub enum Position {
57
    Begin,
58
    End,
59
    At(usize),
×
60
}
61

62
// -- Command result
63

64
/// A command result describes the output of a [`Cmd`] performed on a Component.
65
/// It reports a "logical" change on the `MockComponent`.
66
/// The `Component` then, must return a certain user defined `Msg` based on the value of the [`CmdResult`].
67
#[derive(Debug, PartialEq, Clone)]
×
68
#[allow(clippy::large_enum_variant)]
69
pub enum CmdResult {
70
    /// The component has changed state. The new state is reported.
71
    /// Box is used to reduce size
72
    Changed(State),
×
73
    /// Value submit result
74
    Submit(State),
×
75
    /// The command could not be applied. Useful to report errors
76
    Invalid(Cmd),
×
77
    /// Custom cmd result
NEW
78
    Custom(&'static str, State),
×
79
    /// An array of Command result
80
    Batch(Vec<CmdResult>),
×
81
    /// No result to report
82
    None,
83
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc