blob: d239751a77833c31d982f4059fe58094f5b93445 [file] [log] [blame]
Han-Wen Nienhuys17df8db2021-10-07 20:25:07 +00001/*
2Copyright 2020 Google LLC
3
4Use of this source code is governed by a BSD-style
5license that can be found in the LICENSE file or at
6https://developers.google.com/open-source/licenses/bsd
7*/
8
9#ifndef REFTABLE_GENERIC_H
10#define REFTABLE_GENERIC_H
11
12#include "reftable-iterator.h"
13
14struct reftable_table_vtable;
15
16/*
17 * Provides a unified API for reading tables, either merged tables, or single
18 * readers. */
19struct reftable_table {
20 struct reftable_table_vtable *ops;
21 void *table_arg;
22};
23
24int reftable_table_seek_log(struct reftable_table *tab,
25 struct reftable_iterator *it, const char *name);
26
27int reftable_table_seek_ref(struct reftable_table *tab,
28 struct reftable_iterator *it, const char *name);
29
30/* returns the hash ID from a generic reftable_table */
31uint32_t reftable_table_hash_id(struct reftable_table *tab);
32
33/* returns the max update_index covered by this table. */
34uint64_t reftable_table_max_update_index(struct reftable_table *tab);
35
36/* returns the min update_index covered by this table. */
37uint64_t reftable_table_min_update_index(struct reftable_table *tab);
38
39/* convenience function to read a single ref. Returns < 0 for error, 0
40 for success, and 1 if ref not found. */
41int reftable_table_read_ref(struct reftable_table *tab, const char *name,
42 struct reftable_ref_record *ref);
43
44/* dump table contents onto stdout for debugging */
45int reftable_table_print(struct reftable_table *tab);
46
47#endif