pub struct Merger<'t> { /* fields omitted */ }
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.
Formats the value using the given formatter. Read more