Validate that a confirmation code matches the CLI-generated format. Codes are 3 alphanumeric characters, a dash, then 4 alphanumeric characters (e.g., "AB7-X9KM"). The CLI generates these from the charset `[A-Z2-9]`.
(code: &str)
| 33 | /// Codes are 3 alphanumeric characters, a dash, then 4 alphanumeric characters |
| 34 | /// (e.g., "AB7-X9KM"). The CLI generates these from the charset `[A-Z2-9]`. |
| 35 | fn is_valid_code(code: &str) -> bool { |
| 36 | let bytes = code.as_bytes(); |
| 37 | bytes.len() == 8 |
| 38 | && bytes[3] == b'-' |
| 39 | && bytes[..3] |
| 40 | .iter() |
| 41 | .all(|b| b.is_ascii_uppercase() || b.is_ascii_digit()) |
| 42 | && bytes[4..] |
| 43 | .iter() |
| 44 | .all(|b| b.is_ascii_uppercase() || b.is_ascii_digit()) |
| 45 | } |
| 46 | |
| 47 | #[derive(Deserialize)] |
| 48 | struct ConnectParams { |