Git fork
at reftables-rust 46 lines 1.2 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 BLOCKSOURCE_H 10#define BLOCKSOURCE_H 11 12#include "system.h" 13 14struct reftable_block_source; 15struct reftable_block_data; 16struct reftable_buf; 17 18/* 19 * Close the block source and the underlying resource. This is a no-op in case 20 * the block source is zero-initialized. 21 */ 22void block_source_close(struct reftable_block_source *source); 23 24/* 25 * Read a block of length `size` from the source at the given `off`. 26 */ 27ssize_t block_source_read_data(struct reftable_block_source *source, 28 struct reftable_block_data *dest, uint64_t off, 29 uint32_t size); 30 31/* 32 * Return the total length of the underlying resource. 33 */ 34uint64_t block_source_size(struct reftable_block_source *source); 35 36/* 37 * Return a block to its original source, releasing any resources associated 38 * with it. 39 */ 40void block_source_release_data(struct reftable_block_data *data); 41 42/* Create an in-memory block source for reading reftables. */ 43void block_source_from_buf(struct reftable_block_source *bs, 44 struct reftable_buf *buf); 45 46#endif