(
result: Result<Option<Vec<u8>>, atomic_repository::RepositoryError>,
bytes: &mut usize,
)
| 373 | } |
| 374 | |
| 375 | fn source_text( |
| 376 | result: Result<Option<Vec<u8>>, atomic_repository::RepositoryError>, |
| 377 | bytes: &mut usize, |
| 378 | ) -> SourceText { |
| 379 | match result { |
| 380 | Ok(Some(content)) |
| 381 | if content.len() <= atomic_semantic::MAX_SOURCE_BYTES && content.len() <= *bytes => |
| 382 | { |
| 383 | if content.contains(&0) { |
| 384 | return SourceText::unavailable("Recorded content is binary"); |
| 385 | } |
| 386 | match String::from_utf8(content) { |
| 387 | Ok(text) => { |
| 388 | *bytes -= text.len(); |
| 389 | SourceText::Present { text } |
| 390 | } |
| 391 | Err(_) => SourceText::unavailable("Recorded content is not UTF-8"), |
| 392 | } |
| 393 | } |
| 394 | Ok(Some(_)) => { |
| 395 | SourceText::unavailable("Recorded source exceeds the HTML source byte budget") |
| 396 | } |
| 397 | Ok(None) => SourceText::unavailable( |
| 398 | "Recorded source reference could not be materialized; no working-copy fallback", |
| 399 | ), |
| 400 | Err(error) => SourceText::unavailable(format!("Recorded source unavailable: {error}")), |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | fn escape(text: &str) -> String { |
| 405 | text.replace('&', "&") |
no test coverage detected