reftable/block: expose a generic iterator over reftable records

Expose a generic iterator over reftable records and expose it via the
public interface. Together with an upcoming iterator for reftable blocks
contained in a table this will allow users to trivially iterate through
blocks and their respective records individually.

This functionality will be used to implement consistency checks for the
reftable backend, which requires more fine-grained control over how we
read data.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-04-07 15:16:24 +02:00
committed by Junio C Hamano
parent 6da48a5e00
commit 50d8459477
4 changed files with 140 additions and 1 deletions

View File

@@ -13,6 +13,7 @@
#include "reftable-basics.h"
#include "reftable-blocksource.h"
#include "reftable-iterator.h"
struct z_stream_s;
@@ -60,6 +61,10 @@ int reftable_block_init(struct reftable_block *b,
/* Release resources allocated by the block. */
void reftable_block_release(struct reftable_block *b);
/* Initialize a generic record iterator from the given block. */
int reftable_block_init_iterator(const struct reftable_block *b,
struct reftable_iterator *it);
/* Returns the block type (eg. 'r' for refs). */
uint8_t reftable_block_type(const struct reftable_block *b);