-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathwrapper.c
40 lines (32 loc) · 1.25 KB
/
wrapper.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdlib.h>
#include "flipt_engine.h"
// Declare the Rust functions we're wrapping
extern void* initialize_engine_ffi(const char* namespace, const char* options);
extern const char* evaluate_boolean_ffi(void* engine, const char* request);
extern const char* evaluate_variant_ffi(void* engine, const char* request);
extern const char* evaluate_batch_ffi(void* engine, const char* request);
extern const char* list_flags_ffi(void* engine);
extern void destroy_engine_ffi(void* engine);
extern void destroy_string_ffi(char* str);
// Wrapper functions that will be exported in our .so
void* initialize_engine(const char* namespace, const char* options) {
return initialize_engine_ffi(namespace, options);
}
const char* evaluate_boolean(void* engine, const char* request) {
return evaluate_boolean_ffi(engine, request);
}
const char* evaluate_variant(void* engine, const char* request) {
return evaluate_variant_ffi(engine, request);
}
const char* evaluate_batch(void* engine, const char* request) {
return evaluate_batch_ffi(engine, request);
}
const char* list_flags(void* engine) {
return list_flags_ffi(engine);
}
void destroy_engine(void* engine) {
destroy_engine_ffi(engine);
}
void destroy_string(char* str) {
destroy_string_ffi(str);
}