Skip to main content

TreeDiff

Struct TreeDiff 

Source
pub struct TreeDiff { /* private fields */ }
Available on crate feature diff only.
Expand description

A diff of git trees, holding the ObjectIds of differing files

Implementations§

Source§

impl TreeDiff

Source

pub fn entries(&self) -> &[DiffEntry<(ObjectId, ObjectId)>]

The entries of the diff, one per differing path in the tree

Source§

impl TreeDiff

Source

pub async fn new<F: FileSystem>( repo: &Repo<F>, left: &Tree, right: &Tree, ) -> GResult<Self>

Construct a TreeDiff by diffing two trees

Source

pub async fn new_cancelable<F: FileSystem>( repo: &Repo<F>, left: &Tree, right: &Tree, cancel: impl AsyncFnMut() -> bool, ) -> GResult<Self>

Construct a TreeDiff by diffing two trees

The cancel parameter is a function which may cancel the diff operation by returning true at any point. It is called regularly while the diff operation is running.

For example,

struct CancelableDiffFactory { canceled: Rc<Cell<bool>> }
impl CancelableDiffFactory {
    pub async fn make_diff<F: FileSystem>(
        &self,
        repo: &Repo<F>,
        left: &Tree,
        right: &Tree
    ) -> GResult<TreeDiff> {
        let canceled = self.canceled.clone();
        let cancel = async move || canceled.get();
        TreeDiff::new_cancelable(repo, left, right, cancel).await
    }

    pub fn cancel(&self) {
        self.canceled.set(true);
    }
}

In this example, a diff operation may be started by some async routine, and then canceled by another by calling the CancelableDiffFactory::cancel method.

Source

pub async fn to_text_diff<F: FileSystem>(&self, repo: &Repo<F>) -> GResult<Diff>

Turn the TreeDiff into a Diff by creating a line diff of each file.

Source

pub async fn to_text_diff_full<F: FileSystem>( &self, repo: &Repo<F>, config: &TextDiffConfig, cancel: impl AsyncFnMut() -> bool, ) -> GResult<Diff>

Like TreeDiff::to_text_diff but accepts a similar::TextDiffConfig parameter to configure the file diff operations and a cancel parameter to externally cancel the diff.

The cancel parameter is analogous to the cancel parameter on TreeDiff::new_cancelable; see there for further details.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more