Trait DiffMachine

Source
pub trait DiffMachine {
    // Required methods
    fn diff(
        before: &[u8],
        after: &[u8],
        compress_algorithm: CompressAlgorithm,
    ) -> Result<Patch, Error>;
    fn apply(base: &[u8], delta: &Patch) -> Result<Vec<u8>, Error>;
}
Expand description

A trait that implements differing and patching operations.

This trait defines the core operations needed to generate and apply patches between binary data. Implementations provide specific differing algorithms.

§Example

use files_diff::{DiffMachine, CompressAlgorithm, Error, Patch};
struct MyDiffMachine;

impl DiffMachine for MyDiffMachine {
    fn diff(before: &[u8], after: &[u8], compress: CompressAlgorithm) -> Result<Patch, Error> {
        // Implementation details...
    }
     
    fn apply(base: &[u8], patch: &Patch) -> Result<Vec<u8>, Error> {
        // Implementation details...
    }
}

Required Methods§

Source

fn diff( before: &[u8], after: &[u8], compress_algorithm: CompressAlgorithm, ) -> Result<Patch, Error>

Diff two byte slices using the given compression algorithm.

Source

fn apply(base: &[u8], delta: &Patch) -> Result<Vec<u8>, Error>

Apply a patch to a byte slice.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§