Skip to main content

java_diff_utils_rs/patch/
conflict_output.rs

1use super::delta::Delta;
2use super::error::PatchError;
3use super::verify_chunk::VerifyChunk;
4
5/// Handler function trait for processing diff/patch conflicts.
6pub trait ConflictOutput<T> {
7    /// Processes a conflict that occurred while trying to apply a delta.
8    fn process_conflict(
9        &self,
10        verify_chunk: VerifyChunk,
11        delta: &Delta<T>,
12        result: &mut Vec<T>,
13    ) -> Result<(), PatchError>;
14}
15
16// Blanket implementation allowing closures to be used as `ConflictOutput`.
17impl<T, F> ConflictOutput<T> for F
18where
19    F: Fn(VerifyChunk, &Delta<T>, &mut Vec<T>) -> Result<(), PatchError>,
20{
21    fn process_conflict(
22        &self,
23        verify_chunk: VerifyChunk,
24        delta: &Delta<T>,
25        result: &mut Vec<T>,
26    ) -> Result<(), PatchError> {
27        (self)(verify_chunk, delta, result)
28    }
29}