pub struct Platform<'old, 'new> {
pub old: Object<'old>,
pub new: Object<'new>,
pub algo: Algorithm,
}
Expand description
A platform to keep temporary information to perform line diffs on modified blobs.
Fields§
§old: Object<'old>
The previous version of the blob.
new: Object<'new>
The new version of the blob.
algo: Algorithm
The algorithm to use when calling [imara_diff::diff()][git_diff::blob::diff()].
This value is determined by the diff.algorithm
configuration.
Implementations§
source§impl<'old, 'new> Platform<'old, 'new>
impl<'old, 'new> Platform<'old, 'new>
sourcepub fn from_ids(
previous_id: &Id<'old>,
new_id: &Id<'new>
) -> Result<Platform<'old, 'new>, Error>
pub fn from_ids(
previous_id: &Id<'old>,
new_id: &Id<'new>
) -> Result<Platform<'old, 'new>, Error>
Produce a platform for performing various diffs after obtaining the object data of previous_id
and new_id
.
Note that these objects are treated as raw data and are assumed to be blobs.
Examples found in repository?
40 41 42 43 44 45 46 47 48 49 50 51 52
pub fn diff(
&self,
) -> Option<Result<crate::object::blob::diff::Platform<'old, 'new>, crate::object::blob::diff::init::Error>> {
match self {
Event::Modification {
previous_entry_mode: EntryMode::BlobExecutable | EntryMode::Blob,
previous_id,
entry_mode: EntryMode::BlobExecutable | EntryMode::Blob,
id,
} => Some(crate::object::blob::diff::Platform::from_ids(previous_id, id)),
_ => None,
}
}
source§impl<'old, 'new> Platform<'old, 'new>
impl<'old, 'new> Platform<'old, 'new>
sourcepub fn lines<FnH, E>(&self, process_hunk: FnH) -> Result<(), E>where
FnH: FnMut(Change<'_, '_>) -> Result<(), E>,
E: Error,
pub fn lines<FnH, E>(&self, process_hunk: FnH) -> Result<(), E>where
FnH: FnMut(Change<'_, '_>) -> Result<(), E>,
E: Error,
Perform a diff on lines between the old and the new version of a blob, passing each hunk of lines to process_hunk
.
The diffing algorithm is determined by the diff.algorithm
configuration.
Note that you can invoke the diff more flexibly as well.
sourcepub fn line_counts(&self) -> Counter<()>
pub fn line_counts(&self) -> Counter<()>
Count the amount of removed and inserted lines efficiently.
sourcepub fn line_tokens(&self) -> InternedInput<&[u8]>
pub fn line_tokens(&self) -> InternedInput<&[u8]>
Return a tokenizer which treats lines as smallest unit for use in a [diff operation][git_diff::blob::diff()].
The line separator is determined according to normal git rules and filters.