Normalize a configured compute driver name. Built-in driver names and custom remote driver names share the same selection namespace. The normalized value is lowercase ASCII and may contain letters, digits, `-`, and `_`.
(value: &str)
| 76 | /// selection namespace. The normalized value is lowercase ASCII and may contain |
| 77 | /// letters, digits, `-`, and `_`. |
| 78 | pub fn normalize_compute_driver_name(value: &str) -> Result<String, String> { |
| 79 | let value = value.trim(); |
| 80 | if value.is_empty() { |
| 81 | return Err("compute driver name cannot be empty".to_string()); |
| 82 | } |
| 83 | if !value |
| 84 | .bytes() |
| 85 | .all(|b| b.is_ascii_alphanumeric() || matches!(b, b'-' | b'_')) |
| 86 | { |
| 87 | return Err(format!( |
| 88 | "invalid compute driver name '{value}'. use ASCII letters, digits, '-' or '_'" |
| 89 | )); |
| 90 | } |
| 91 | Ok(value.to_ascii_lowercase()) |
| 92 | } |
| 93 | |
| 94 | impl fmt::Display for ComputeDriverKind { |
| 95 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |