[−][src]Struct dogear::Merger
A two-way merger that produces a complete merged tree from a complete local tree and a complete remote tree with changes since the last sync.
This is ported almost directly from iOS. On iOS, the ThreeWayMerger
takes
a complete "mirror" tree with the server state after the last sync, and two
incomplete trees with local and remote changes to the mirror: "local" and
"mirror", respectively. Overlaying buffer onto mirror yields the current
server tree; overlaying local onto mirror yields the complete local tree.
Dogear doesn't store the shared parent for changed items, so we can only do two-way merges. Our local tree is the union of iOS's mirror and local, and our remote tree is the union of iOS's mirror and buffer.
Unlike iOS, Dogear doesn't distinguish between structure and value changes.
The needs_merge
flag notes that a bookmark changed, but not how. This
means we might detect conflicts, and revert changes on one side, for cases
that iOS can merge cleanly.
Fortunately, most of our users don't organize their bookmarks into deeply nested hierarchies, or make conflicting changes on multiple devices simultaneously. A simpler two-way tree merge strikes a good balance between correctness and complexity.
Methods
impl<'t, D: Driver, A: AbortSignal> Merger<'t, D, A>
[src]
pub fn with_driver(
driver: &'t D,
signal: &'t A,
local_tree: &'t Tree,
new_local_contents: &'t HashMap<Guid, Content>,
remote_tree: &'t Tree,
new_remote_contents: &'t HashMap<Guid, Content>
) -> Merger<'t, D, A>
[src]
driver: &'t D,
signal: &'t A,
local_tree: &'t Tree,
new_local_contents: &'t HashMap<Guid, Content>,
remote_tree: &'t Tree,
new_remote_contents: &'t HashMap<Guid, Content>
) -> Merger<'t, D, A>
Creates a merger with the given merge driver and contents.
pub fn merge(&mut self) -> Result<MergedRoot<'t>>
[src]
Builds a merged tree from the local and remote trees.
pub fn subsumes(&self, tree: &Tree) -> bool
[src]
Checks if the merger merged all GUIDs in the given tree.
pub fn deletions(&self) -> impl Iterator<Item = Deletion>
[src]
Returns an iterator for all accepted local and remote deletions.
pub fn counts(&self) -> &StructureCounts
[src]
Returns structure change counts for this merge.
Auto Trait Implementations
impl<'t, D, A> Send for Merger<'t, D, A> where
A: Sync,
D: Sync,
A: Sync,
D: Sync,
impl<'t, D, A> Sync for Merger<'t, D, A> where
A: Sync,
D: Sync,
A: Sync,
D: Sync,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,