(value: &str)
| 206 | } |
| 207 | |
| 208 | fn parse_modifier_mask(value: &str) -> Result<u32, crate::error::AppError> { |
| 209 | let mut mask = 0; |
| 210 | for token in value |
| 211 | .split(',') |
| 212 | .map(str::trim) |
| 213 | .filter(|token| !token.is_empty()) |
| 214 | { |
| 215 | mask |= match token.to_lowercase().as_str() { |
| 216 | "shift" | "225" | "left-shift" => 1, |
| 217 | "ctrl" | "control" | "224" | "left-control" => 1 << 1, |
| 218 | "alt" | "option" | "226" | "left-option" => 1 << 2, |
| 219 | "cmd" | "command" | "meta" | "227" | "left-command" => 1 << 3, |
| 220 | "caps" | "caps-lock" | "57" => 1 << 4, |
| 221 | other => { |
| 222 | return Err(crate::error::AppError::bad_request(format!( |
| 223 | "Unsupported modifier `{other}`." |
| 224 | ))) |
| 225 | } |
| 226 | }; |
| 227 | } |
| 228 | Ok(mask) |
| 229 | } |
no test coverage detected