vuquest_3320/command/
query.rs1const DEFAULT_VALUE: &str = "^";
2const CURRENT_VALUE: &str = "?";
3const RANGE_VALUE: &str = "*";
4
5#[derive(Clone, Copy, Debug, Eq, PartialEq)]
7pub enum QueryCommand {
8 DefaultValue,
10 CurrentValue,
12 RangeValue,
14}
15
16impl QueryCommand {
17 pub const fn new() -> Self {
19 Self::DefaultValue
20 }
21
22 pub const fn command(&self) -> &str {
24 match self {
25 Self::DefaultValue => DEFAULT_VALUE,
26 Self::CurrentValue => CURRENT_VALUE,
27 Self::RangeValue => RANGE_VALUE,
28 }
29 }
30}
31
32impl Default for QueryCommand {
33 fn default() -> Self {
34 Self::new()
35 }
36}
37
38#[cfg(test)]
39mod tests {
40 use super::*;
41
42 #[test]
43 fn test_valid() {
44 [
45 QueryCommand::DefaultValue,
46 QueryCommand::CurrentValue,
47 QueryCommand::RangeValue,
48 ]
49 .into_iter()
50 .zip([DEFAULT_VALUE, CURRENT_VALUE, RANGE_VALUE])
51 .for_each(|(cmd, exp_ascii)| {
52 assert_eq!(cmd.command(), exp_ascii);
53 });
54 }
55}