amduat/include/amduat/asl/log_store.h
2026-01-23 19:04:49 +01:00

63 lines
1.6 KiB
C

#ifndef AMDUAT_ASL_LOG_STORE_H
#define AMDUAT_ASL_LOG_STORE_H
#include "amduat/asl/asl_pointer_fs.h"
#include "amduat/asl/core.h"
#include "amduat/asl/store.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
enum { TYPE_TAG_ASL_LOG_CHUNK_1 = 0x00000401u };
enum { AMDUAT_TYPE_TAG_ASL_LOG_CHUNK_1 = TYPE_TAG_ASL_LOG_CHUNK_1 };
typedef struct {
uint16_t kind;
bool has_timestamp;
uint64_t timestamp;
amduat_reference_t payload_ref;
bool has_actor;
amduat_octets_t actor;
} amduat_asl_log_entry_t;
typedef struct {
amduat_asl_store_t *store;
amduat_asl_pointer_store_t pointer_store;
} amduat_asl_log_store_t;
bool amduat_asl_log_store_init(amduat_asl_log_store_t *log_store,
const char *root_path,
amduat_asl_store_t *store,
const amduat_asl_pointer_store_t *pointer_store);
amduat_asl_store_error_t amduat_asl_log_append(
amduat_asl_log_store_t *log_store,
const char *log_name,
const amduat_asl_log_entry_t *entries,
size_t entries_len,
uint64_t *out_first_offset);
amduat_asl_store_error_t amduat_asl_log_read(
amduat_asl_log_store_t *log_store,
const char *log_name,
uint64_t from_offset,
size_t max_entries,
amduat_asl_log_entry_t **out_entries,
size_t *out_len,
uint64_t *out_next_offset,
bool *out_end);
void amduat_asl_log_entries_free(amduat_asl_log_entry_t *entries,
size_t entries_len);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* AMDUAT_ASL_LOG_STORE_H */