pub struct DiffFile { /* private fields */ }Expand description
One changed file parsed from a unified or Git diff.
Only source fragments present in the patch are retained; unavailable context is never reconstructed or compared. Cloning is cheap.
Implementations§
Source§impl DiffFile
impl DiffFile
Sourcepub fn unchanged(path: impl Into<SharedString>, text: &str) -> Self
pub fn unchanged(path: impl Into<SharedString>, text: &str) -> Self
A file shown in full, for reference, without changes. It appears as a single column in every display mode.
Sourcepub fn parse_conflicts(
path: impl Into<SharedString>,
text: &str,
) -> Result<Self, DiffParseError>
pub fn parse_conflicts( path: impl Into<SharedString>, text: &str, ) -> Result<Self, DiffParseError>
Parses a working file containing Git conflict markers, including the
||||||| base section of diff3 style. Lines keep their numbers in
the working file; marker lines are shown as conflict headings instead.
Source§impl DiffFile
impl DiffFile
Sourcepub fn parse(patch: &str) -> Result<Vec<Self>, DiffParseError>
pub fn parse(patch: &str) -> Result<Vec<Self>, DiffParseError>
Parses every file in a unified or Git diff, in patch order, without
computing differences. Syntax emphasis is prepared later by
super::DiffState on a background thread.
Sourcepub fn with_language(self, language: impl Into<SharedString>) -> Self
pub fn with_language(self, language: impl Into<SharedString>) -> Self
Overrides the syntax language detected from the path, using a
highlighter language name such as rust or javascript.
Sourcepub fn language(&self) -> SharedString
pub fn language(&self) -> SharedString
The syntax language: the override, or the one detected from the path.
Sourcepub fn status(&self) -> DiffFileStatus
pub fn status(&self) -> DiffFileStatus
How the file changed.
Sourcepub fn path(&self) -> &SharedString
pub fn path(&self) -> &SharedString
The path to show for this file: the modified path, or the original path of a deleted file.
Sourcepub fn original_path(&self) -> Option<&SharedString>
pub fn original_path(&self) -> Option<&SharedString>
The original path, or None for an added file.
Sourcepub fn modified_path(&self) -> Option<&SharedString>
pub fn modified_path(&self) -> Option<&SharedString>
The modified path, or None for a deleted file.
Sourcepub fn extended_headers(&self) -> &[SharedString]
pub fn extended_headers(&self) -> &[SharedString]
Git extended header lines, such as file modes, similarity, renames and the binary marker, as they appear in the patch.
Sourcepub fn is_binary(&self) -> bool
pub fn is_binary(&self) -> bool
Whether the patch reports binary contents rather than textual hunks.
pub fn additions(&self) -> usize
pub fn deletions(&self) -> usize
Sourcepub fn has_changes(&self) -> bool
pub fn has_changes(&self) -> bool
Whether the file changes, including an added or deleted empty file and metadata-only changes such as a mode change or pure rename.
Sourcepub fn conflicts(&self) -> &[DiffConflict]
pub fn conflicts(&self) -> &[DiffConflict]
Merge conflicts in working-file order; slice indices identify resolutions.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DiffFile
impl RefUnwindSafe for DiffFile
impl Send for DiffFile
impl Sync for DiffFile
impl Unpin for DiffFile
impl UnsafeUnpin for DiffFile
impl UnwindSafe for DiffFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more