equal
deleted
inserted
replaced
40 const VALID_MESSAGES: &[u8] = |
40 const VALID_MESSAGES: &[u8] = |
41 b"M#+LlRrUuDdZzAaSjJ,NpPwtgfhbc12345\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A"; |
41 b"M#+LlRrUuDdZzAaSjJ,NpPwtgfhbc12345\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A"; |
42 const NON_TIMED_MESSAGES: &[u8] = b"M#hb"; |
42 const NON_TIMED_MESSAGES: &[u8] = b"M#hb"; |
43 |
43 |
44 fn is_msg_valid(msg: &[u8], team_indices: &[u8]) -> bool { |
44 fn is_msg_valid(msg: &[u8], team_indices: &[u8]) -> bool { |
45 if let [size, typ, body..] = msg { |
45 match msg { |
46 VALID_MESSAGES.contains(typ) && |
46 [size, typ, body..] => VALID_MESSAGES.contains(typ) |
47 match body { |
47 && match body { |
48 [1...8, team, ..] if *typ == b'h' => team_indices.contains(team), |
48 [1...8, team, ..] if *typ == b'h' => team_indices.contains(team), |
49 _ => *typ != b'h' |
49 _ => *typ != b'h' |
50 } |
50 }, |
51 } else { |
51 _ => false |
52 false |
|
53 } |
52 } |
54 } |
53 } |
55 |
54 |
56 fn is_msg_empty(msg: &[u8]) -> bool { |
55 fn is_msg_empty(msg: &[u8]) -> bool { |
57 match msg { |
56 match msg { |