Skip to main content

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 crate::blob::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 contains a DiffLineKind and the original token bytes (&[u8]) for that line without the unified diff prefix character. The header specifies hunk offsets, which positions the lines in the old and new file respectively.

Note that crate::blob::UnifiedDiff 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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

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

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

Source§

type Out = D