ConsumeHunk

Trait ConsumeHunk 

Source
pub trait ConsumeHunk {
    type Out;

    // Required methods
    fn consume_hunk(
        &mut self,
        header: HunkHeader,
        lines: &[(DiffLineKind, &[u8])],
    ) -> Result<()>;
    fn finish(self) -> Self::Out;
}
Available on crate feature blob only.
Expand description

A utility trait for use in UnifiedDiff.

Required Associated Types§

Source

type Out

The item this instance produces after consuming all hunks.

Required Methods§

Source

fn consume_hunk( &mut self, header: HunkHeader, lines: &[(DiffLineKind, &[u8])], ) -> Result<()>

Consume a single hunk which is represented by its lines, each of which with a DiffLineKind value to know if it’s added, removed or context. The header specifies hunk offsets, which positions the lines in the old and new file respectively.

Note that the UnifiedDiff sink will wrap its output in an std::io::Result. After this method returned its first error, it will not be called anymore.

Source

fn finish(self) -> Self::Out

Called after the last hunk is consumed to produce an output.

Implementors§

Source§

impl<D> ConsumeHunk for ConsumeBinaryHunk<'_, D>

An implementation that fails if the input isn’t UTF-8.

Source§

type Out = D