Returns `true` if `data` contains only safe characters for sysfs values (alphanumeric plus `:`, `.`, `-`, `_`).
(data: &str)
| 201 | /// Returns `true` if `data` contains only safe characters for sysfs values |
| 202 | /// (alphanumeric plus `:`, `.`, `-`, `_`). |
| 203 | pub fn validate_sysfs_data(data: &str) -> bool { |
| 204 | !data.is_empty() |
| 205 | && data |
| 206 | .chars() |
| 207 | .all(|c| c.is_alphanumeric() || matches!(c, ':' | '.' | '-' | '_')) |
| 208 | } |
| 209 | |
| 210 | pub(crate) fn read_sysfs_trimmed(path: &Path) -> Result<String, VfioError> { |
| 211 | fs::read_to_string(path) |