negentropy/cpp/negentropy_wrapper.h

75 lines
2.1 KiB
C
Raw Normal View History

2024-02-22 16:47:07 +05:30
#ifndef _NEGENTROPY_WRAPPER_H
#define _NEGENTROPY_WRAPPER_H
2024-02-16 15:15:59 +05:30
#ifdef __cplusplus
#define EXTERNC extern "C"
#else
#define EXTERNC
#endif
2024-02-16 17:34:49 +05:30
typedef struct _buffer_{
uint64_t len ;
2024-03-04 16:28:35 +05:30
unsigned char* data;
}buffer;
typedef struct _result_ {
buffer output;
uint64_t have_ids_len;
uint64_t need_ids_len;
buffer* have_ids;
buffer* need_ids;
2024-03-14 15:29:21 +05:30
char* error;
} result;
2024-02-16 15:15:59 +05:30
//This is a C-wrapper for the C++ library that helps in integrating negentropy with nim code.
//TODO: Do error handling by catching exceptions
EXTERNC void* storage_new(const char* db_path, const char* name);
2024-02-16 15:15:59 +05:30
2024-03-07 16:02:47 +05:30
EXTERNC void storage_delete(void* storage);
2024-03-11 14:01:21 +05:30
EXTERNC int storage_size(void* storage);
EXTERNC void* negentropy_new(void* storage, uint64_t frameSizeLimit);
2024-02-16 15:15:59 +05:30
2024-03-07 16:02:47 +05:30
EXTERNC void negentropy_delete(void* negentropy);
2024-03-13 15:43:05 +05:30
EXTERNC int negentropy_initiate(void* negentropy, result* result);
2024-02-16 15:15:59 +05:30
EXTERNC void negentropy_setinitiator(void* negentropy);
2024-02-16 15:15:59 +05:30
EXTERNC bool storage_insert(void* storage, uint64_t createdAt, buffer* id);
2024-02-16 15:15:59 +05:30
EXTERNC bool storage_erase(void* storage, uint64_t createdAt, buffer* id);
2024-02-16 17:34:49 +05:30
2024-03-13 15:43:05 +05:30
EXTERNC int reconcile(void* negentropy, buffer* query, result* result);
2024-03-05 11:27:30 +05:30
EXTERNC typedef void (*reconcile_cbk)(buffer* have_ids, uint64_t have_ids_len, buffer* need_ids, uint64_t need_ids_len, buffer* output, char* outptr );
2024-03-05 11:27:30 +05:30
EXTERNC int reconcile_with_ids(void* negentropy, buffer* query, reconcile_cbk cbk, char* outptr);
2024-02-16 17:34:49 +05:30
2024-03-14 15:29:21 +05:30
EXTERNC int reconcile_with_ids_no_cbk(void* negentropy, buffer* query, result* result);
EXTERNC void free_result(result* result);
2024-02-16 17:34:49 +05:30
2024-04-30 14:19:03 +05:30
//SubRange methods
EXTERNC void* subrange_new(void* storage, uint64_t startTimeStamp, uint64_t endTimeStamp);
EXTERNC void subrange_delete(void* range);
EXTERNC void* negentropy_subrange_new(void* subrange, uint64_t frameSizeLimit);
EXTERNC void negentropy_subrange_delete(void* negentropy);
EXTERNC int negentropy_subrange_initiate(void* negentropy, result* result);
EXTERNC int reconcile_subrange(void* negentropy, buffer* query, result* result);
EXTERNC int reconcile_with_ids_subrange_no_cbk(void* negentropy, buffer* query, result* result);
//End of SubRange methods
#endif
2024-02-16 17:34:49 +05:30