blob: 39251aee93114470cb219c8b0c672905e917d22c [file] [log] [blame]
// Copyright 2017 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SRC_LEDGER_BIN_STORAGE_IMPL_BTREE_DIFF_H_
#define SRC_LEDGER_BIN_STORAGE_IMPL_BTREE_DIFF_H_
#include <lib/fit/function.h>
#include <functional>
#include "src/ledger/bin/storage/impl/btree/tree_node.h"
#include "src/ledger/bin/storage/public/types.h"
#include "src/ledger/lib/coroutine/coroutine.h"
namespace storage {
namespace btree {
// Iterates through the differences between two trees given their root ids
// |base_root_id| and |other_root_id| and calls |on_next| on found differences.
// Returning false from |on_next| will immediately stop the iteration. |on_done|
// is called once, upon successfull completion, i.e. when there are no more
// differences or iteration was interrupted, or if an error occurs.
void ForEachDiff(coroutine::CoroutineService* coroutine_service,
PageStorage* page_storage,
ObjectIdentifier base_root_identifier,
ObjectIdentifier other_root_identifier, std::string min_key,
fit::function<bool(EntryChange)> on_next,
fit::function<void(Status)> on_done);
// Iterates through the differences between three trees given their root ids and
// calls |on_next| if any difference is found between any pair.
// Returning false from |on_next| will immediately stop the iteration. |on_done|
// is called once, upon successful completion, i.e. when there are no more
// differences or iteration was interrupted, or if an error occurs.
void ForEachThreeWayDiff(coroutine::CoroutineService* coroutine_service,
PageStorage* page_storage,
ObjectIdentifier base_root_identifier,
ObjectIdentifier left_root_identifier,
ObjectIdentifier right_root_identifier,
std::string min_key,
fit::function<bool(ThreeWayChange)> on_next,
fit::function<void(Status)> on_done);
} // namespace btree
} // namespace storage
#endif // SRC_LEDGER_BIN_STORAGE_IMPL_BTREE_DIFF_H_