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>
impl<'a> Changes<'a>
sourcepub fn needed_to_obtain<R, StateMut>(
self,
other: TreeRefIter<'_>,
state: StateMut,
objects: impl Find,
delegate: &mut R
) -> Result<(), Error>
pub fn needed_to_obtain<R, StateMut>( self, other: TreeRefIter<'_>, state: StateMut, objects: impl Find, delegate: &mut R ) -> Result<(), Error>
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 functionf(object_id, &mut buffer) -> Option<TreeIter>
to return aTreeIter
for the given object id backing its data in the given buffer. ReturningNone
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 theVisit
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 becausePeekable
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§
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> 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
Mutably borrows from an owned value. Read more