Process a single file on a rayon worker thread. This function is the per-file workhorse. It reads the file from disk, diffs against old content, tokenizes, and builds hunks. It is designed to be called from a rayon parallel iterator and must not access any shared mutable state.
(
input: &FileRecordInput,
options: &RecordingOptions,
)
| 19 | /// to be called from a rayon parallel iterator and must not access any |
| 20 | /// shared mutable state. |
| 21 | pub fn process_single_file( |
| 22 | input: &FileRecordInput, |
| 23 | options: &RecordingOptions, |
| 24 | ) -> Result<FileRecordOutput, String> { |
| 25 | let file_start = Instant::now(); |
| 26 | |
| 27 | let result = match input.kind { |
| 28 | FileRecordKind::Added => process_added_file(input, options), |
| 29 | FileRecordKind::Modified => process_modified_file(input, options), |
| 30 | FileRecordKind::Deleted => process_deleted_file(input, options), |
| 31 | FileRecordKind::DirectoryAdded => process_directory_added(input), |
| 32 | FileRecordKind::DirectoryDeleted => process_directory_deleted(input), |
| 33 | }; |
| 34 | |
| 35 | // Attach timing to the result |
| 36 | let elapsed = file_start.elapsed().as_millis() as u64; |
| 37 | result.map(|mut output| { |
| 38 | output.stats.processing_time_ms = elapsed; |
| 39 | output |
| 40 | }) |
| 41 | } |
| 42 | |
| 43 | /// Process an added file: read content, detect encoding, create hunks, tokenize. |
| 44 | fn process_added_file( |
no test coverage detected