(value: &str)
| 186 | } |
| 187 | |
| 188 | fn safe_file_stem(value: &str) -> String { |
| 189 | let mut out = String::with_capacity(value.len().min(64)); |
| 190 | for ch in value.chars().take(64) { |
| 191 | if ch.is_ascii_alphanumeric() || ch == '-' || ch == '_' { |
| 192 | out.push(ch); |
| 193 | } else { |
| 194 | out.push('_'); |
| 195 | } |
| 196 | } |
| 197 | if out.is_empty() { |
| 198 | "image".to_string() |
| 199 | } else { |
| 200 | out |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | fn has_text(value: Option<&str>) -> bool { |
| 205 | value.is_some_and(|value| !value.trim().is_empty()) |