Struct gix_diff::tree::Changes

source ·
pub struct Changes<'a>(/* private fields */);
Expand description

An iterator over changes of a tree, instantiated using Changes::from(…).

Implementations§

source§

impl<'a> Changes<'a>

source

pub fn needed_to_obtain<R, StateMut>( self, other: TreeRefIter<'_>, state: StateMut, objects: impl Find, delegate: &mut R ) -> Result<(), Error>
where R: Visit, StateMut: BorrowMut<State>,

Calculate the changes that would need to be applied to self to get other using objects to obtain objects as needed for traversal.

  • The state maybe owned or mutably borrowed to allow reuses allocated data structures through multiple runs.
  • locate is a function f(object_id, &mut buffer) -> Option<TreeIter> to return a TreeIter for the given object id backing its data in the given buffer. Returning None is unexpected as these trees are obtained during iteration, and in a typical database errors are not expected either which is why the error case is omitted. To allow proper error reporting, Error::Find should be converted into a more telling error.
  • delegate will receive the computed changes, see the Visit trait for more information on what to expect.
Notes
  • To obtain progress, implement it within the delegate.
  • Tree entries are expected to be ordered using tree-entry-comparison (the same in Rust)
  • it does a breadth first iteration as buffer space only fits two trees, the current one on the one we compare with.
  • does not do rename tracking but attempts to reduce allocations to zero (so performance is mostly determined by the delegate implementation which should be as specific as possible. Rename tracking can be computed on top of the changes received by the delegate.
  • cycle checking is not performed, but can be performed in the delegate which can return tree::visit::Action::Cancel to stop the traversal.
  • std::mem::ManuallyDrop is used because Peekable is needed. When using it as wrapper around our no-drop iterators, all of the sudden borrowcheck complains as Drop is present (even though it’s not)

Trait Implementations§

source§

impl<'a, T> From<T> for Changes<'a>
where T: Into<Option<TreeRefIter<'a>>>,

source§

fn from(v: T) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Changes<'a>

§

impl<'a> Send for Changes<'a>

§

impl<'a> Sync for Changes<'a>

§

impl<'a> Unpin for Changes<'a>

§

impl<'a> UnwindSafe for Changes<'a>

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>,

§

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>,

§

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.