pub struct FileDiff {
pub old_path: Option<RepoPath>,
pub path: RepoPath,
pub status: FileStatus,
pub staged: StageState,
pub hunks: Vec<Hunk>,
pub binary: bool,
pub mode: Option<ModeChange>,
pub no_newline_at_end: bool,
pub omitted_bytes: Option<u64>,
pub old_source: Result<Arc<SourceDocument>, SourceUnavailable>,
pub new_source: Result<Arc<SourceDocument>, SourceUnavailable>,
}Expand description
One changed file.
old_source and new_source hold the complete versions of each side.
When both are available the hunks are derived from them, so equal sides
imply equal hunks; otherwise the hunks are the patch as supplied.
Fields§
§old_path: Option<RepoPath>§path: RepoPath§status: FileStatus§staged: StageState§hunks: Vec<Hunk>§binary: bool§mode: Option<ModeChange>§no_newline_at_end: bool§omitted_bytes: Option<u64>§old_source: Result<Arc<SourceDocument>, SourceUnavailable>§new_source: Result<Arc<SourceDocument>, SourceUnavailable>Implementations§
Source§impl FileDiff
impl FileDiff
Sourcepub fn path_for_side(&self, side: DiffSide) -> &RepoPath
pub fn path_for_side(&self, side: DiffSide) -> &RepoPath
Returns the repository path used by one side of this file version.
Sourcepub fn from_texts<T>(
path: T,
old: &str,
new: &str,
) -> Result<FileDiff, DiffError>
pub fn from_texts<T>( path: T, old: &str, new: &str, ) -> Result<FileDiff, DiffError>
Builds a one-file diff from complete old and new text snapshots.
§Errors
Returns an error when path is not a valid repository-relative path.
Sourcepub fn with_sources(
self,
old: Result<Arc<SourceDocument>, SourceUnavailable>,
new: Result<Arc<SourceDocument>, SourceUnavailable>,
) -> FileDiff
pub fn with_sources( self, old: Result<Arc<SourceDocument>, SourceUnavailable>, new: Result<Arc<SourceDocument>, SourceUnavailable>, ) -> FileDiff
Attaches captured source versions, re-deriving the hunks from them when both sides are known. Git metadata such as status, staging, mode, and paths is kept as supplied; a binary file keeps its patch untouched.
Sourcepub const fn uncaptured_source(
status: FileStatus,
side: DiffSide,
) -> Result<Arc<SourceDocument>, SourceUnavailable>
pub const fn uncaptured_source( status: FileStatus, side: DiffSide, ) -> Result<Arc<SourceDocument>, SourceUnavailable>
The source result recorded for a side of a file whose complete versions were not captured.
§Errors
Always an unavailable reason: SourceUnavailable::Absent where the
status says the side cannot exist, SourceUnavailable::NotCaptured
otherwise.
Sourcepub const fn source(
&self,
side: DiffSide,
) -> &Result<Arc<SourceDocument>, SourceUnavailable>
pub const fn source( &self, side: DiffSide, ) -> &Result<Arc<SourceDocument>, SourceUnavailable>
Returns the complete source result for one side.
Sourcepub fn source_document(&self, side: DiffSide) -> Option<&Arc<SourceDocument>>
pub fn source_document(&self, side: DiffSide) -> Option<&Arc<SourceDocument>>
Returns the complete source document for one side when it is available.
Returns why one side has no complete source document.
Sourcepub fn content_id(&self) -> Fingerprint
pub fn content_id(&self) -> Fingerprint
Content identity used to decide whether presentation state derived from this file, such as revealed gaps, still applies after a replacement.
The identity covers both sides. When either side is unavailable the hunks are the content and are covered too; when both are available the hunks are derived from them and add nothing.
pub fn line(&self, hunk: usize, line: usize) -> Option<&PatchLine>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FileDiff
impl<'de> Deserialize<'de> for FileDiff
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<FileDiff, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<FileDiff, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for FileDiff
Source§impl Serialize for FileDiff
impl Serialize for FileDiff
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for FileDiff
Auto Trait Implementations§
impl Freeze for FileDiff
impl RefUnwindSafe for FileDiff
impl Send for FileDiff
impl Sync for FileDiff
impl Unpin for FileDiff
impl UnsafeUnpin for FileDiff
impl UnwindSafe for FileDiff
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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