pub struct MMFile { /* private fields */ }Expand description
Type representing an owned, compact file in libxdiff
Implementations§
Source§impl MMFile
impl MMFile
Sourcepub fn from_bytes(bytes: &[u8]) -> MMFile
pub fn from_bytes(bytes: &[u8]) -> MMFile
Create a new MMFile initialized with contents
Sourcepub fn is_compact(&self) -> bool
pub fn is_compact(&self) -> bool
Checks if the entire file is a single allocation. In our library this is always true.
Sourcepub fn compute_patch(&mut self, other: &mut Self) -> Result<MMPatch, String>
pub fn compute_patch(&mut self, other: &mut Self) -> Result<MMPatch, String>
Compute the patch to turn self into other
Sourcepub fn apply_patch(
&mut self,
patch: &mut MMPatch,
) -> Result<MMFile, (MMFile, MMFile)>
pub fn apply_patch( &mut self, patch: &mut MMPatch, ) -> Result<MMFile, (MMFile, MMFile)>
Apply a patch to a file. If successful, return the new file. If unsuccessful, return (successfully patched part, rejected parts)
Sourcepub fn diff_raw<CB>(
&mut self,
other: &mut MMFile,
callback: CB,
) -> Result<(), String>
pub fn diff_raw<CB>( &mut self, other: &mut MMFile, callback: CB, ) -> Result<(), String>
Compute the diff to turn self into other, returning diff through a
callback one line at a time. Returns Err if callback panics.
Sourcepub unsafe fn diff_raw_nopanic<CB>(
&mut self,
other: &mut MMFile,
callback: CB,
) -> Result<(), String>
pub unsafe fn diff_raw_nopanic<CB>( &mut self, other: &mut MMFile, callback: CB, ) -> Result<(), String>
Compute the diff to turn self into other, returning diff through a callback one line at a time. Callback should return 0 on success and -1 on failure.
§Safety
The provided callback must not panic
Sourcepub fn merge3_raw<CBA, CBR>(
base: &mut MMFile,
f1: &mut MMFile,
f2: &mut MMFile,
accept_callback: CBA,
reject_callback: CBR,
) -> Result<(), String>
pub fn merge3_raw<CBA, CBR>( base: &mut MMFile, f1: &mut MMFile, f2: &mut MMFile, accept_callback: CBA, reject_callback: CBR, ) -> Result<(), String>
Compute the file that results from merging two sets of changes to the
base file. The resulting file is passed line-by-line to the
accept_callback, any conflicting changes are passed to the
reject_callback. Returns Err if any callback panics; panicking
should be avoided wherever possible.
Sourcepub fn as_slice_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_slice_mut(&mut self) -> &mut [u8] ⓘ
Get a mutable view of the MMFile’s data as a slice