#include #include #include #include typedef enum OperationStatus { Ok = 0, NullPointer = 1, InitializationError = 2, } OperationStatus; typedef struct IndexerServiceFFI { void *indexer_handle; void *runtime; } IndexerServiceFFI; /** * Simple wrapper around a pointer to a value or an error. * * Pointer is not guaranteed. You should check the error field before * dereferencing the pointer. */ typedef struct PointerResult_IndexerServiceFFI__OperationStatus { struct IndexerServiceFFI *value; enum OperationStatus error; } PointerResult_IndexerServiceFFI__OperationStatus; typedef struct PointerResult_IndexerServiceFFI__OperationStatus InitializedIndexerServiceFFIResult; /** * Creates and starts an indexer based on the provided * configuration file path. * * # Arguments * * - `config_path`: A pointer to a string representing the path to the configuration file. * - `port`: Number representing a port, on which indexers RPC will start. * * # Returns * * An `InitializedIndexerServiceFFIResult` containing either a pointer to the * initialized `IndexerServiceFFI` or an error code. */ InitializedIndexerServiceFFIResult start_indexer(const char *config_path, uint16_t port); /** * Stops and frees the resources associated with the given indexer service. * * # Arguments * * - `indexer`: A pointer to the `IndexerServiceFFI` instance to be stopped. * * # Returns * * An `OperationStatus` indicating success or failure. * * # Safety * * The caller must ensure that: * - `indexer` is a valid pointer to a `IndexerServiceFFI` instance * - The `IndexerServiceFFI` instance was created by this library * - The pointer will not be used after this function returns */ enum OperationStatus stop_indexer(struct IndexerServiceFFI *indexer); /** * # Safety * It's up to the caller to pass a proper pointer, if somehow from c/c++ side * this is called with a type which doesn't come from a returned `CString` it * will cause a segfault. */ void free_cstring(char *block); bool is_ok(const enum OperationStatus *self); bool is_error(const enum OperationStatus *self);