Git fork
at reftables-rust 60 lines 1.8 kB view raw
1/* 2 * Copyright 2020 Google LLC 3 * 4 * Use of this source code is governed by a BSD-style 5 * license that can be found in the LICENSE file or at 6 * https://developers.google.com/open-source/licenses/bsd 7 */ 8 9#ifndef REFTABLE_ITERATOR_H 10#define REFTABLE_ITERATOR_H 11 12#include "reftable-record.h" 13 14struct reftable_iterator_vtable; 15 16/* iterator is the generic interface for walking over data stored in a 17 * reftable. 18 */ 19struct reftable_iterator { 20 struct reftable_iterator_vtable *ops; 21 void *iter_arg; 22}; 23 24/* 25 * Position the iterator at the ref record with given name such that the next 26 * call to `next_ref()` would yield the record. 27 */ 28int reftable_iterator_seek_ref(struct reftable_iterator *it, 29 const char *name); 30 31/* reads the next reftable_ref_record. Returns < 0 for error, 0 for OK and > 0: 32 * end of iteration. 33 */ 34int reftable_iterator_next_ref(struct reftable_iterator *it, 35 struct reftable_ref_record *ref); 36 37/* 38 * Position the iterator at the log record with given name and update index 39 * such that the next call to `next_log()` would yield the record. 40 */ 41int reftable_iterator_seek_log_at(struct reftable_iterator *it, 42 const char *name, uint64_t update_index); 43 44/* 45 * Position the iterator at the newest log record with given name such that the 46 * next call to `next_log()` would yield the record. 47 */ 48int reftable_iterator_seek_log(struct reftable_iterator *it, 49 const char *name); 50 51/* reads the next reftable_log_record. Returns < 0 for error, 0 for OK and > 0: 52 * end of iteration. 53 */ 54int reftable_iterator_next_log(struct reftable_iterator *it, 55 struct reftable_log_record *log); 56 57/* releases resources associated with an iterator. */ 58void reftable_iterator_destroy(struct reftable_iterator *it); 59 60#endif