refactor(rust): add Rust wrapper for every CStruct

we want to wrap CStructs in RustStructs to own them, and free memeory
when they are no longer used. Users won't have to deal with the direct
binded CAPI, but the new wrappers
This commit is contained in:
youben11
2022-12-08 10:00:54 +01:00
committed by Quentin Bourgerie
parent aa2e0479b3
commit 8c6a0859cd
3 changed files with 1090 additions and 720 deletions

View File

@@ -84,13 +84,16 @@ CompilationOptions compilationOptionsCreateDefault() {
return wrap(new mlir::concretelang::CompilationOptions("main"));
}
void compilationOptionsDestroy(CompilationOptions options){
C_STRUCT_CLEANER(options)}
/// ********** OptimizerConfig CAPI ********************************************
OptimizerConfig optimizerConfigCreate(bool display,
double fallback_log_norm_woppbs,
double global_p_error, double p_error,
uint64_t security, bool strategy_v0,
bool use_gpu_constraints) {
OptimizerConfig
optimizerConfigCreate(bool display, double fallback_log_norm_woppbs,
double global_p_error, double p_error,
uint64_t security, bool strategy_v0,
bool use_gpu_constraints) {
auto config = new mlir::concretelang::optimizer::Config();
config->display = display;
config->fallback_log_norm_woppbs = fallback_log_norm_woppbs;
@@ -106,6 +109,8 @@ OptimizerConfig optimizerConfigCreateDefault() {
return wrap(new mlir::concretelang::optimizer::Config());
}
void optimizerConfigDestroy(OptimizerConfig config){C_STRUCT_CLEANER(config)}
/// ********** CompilerEngine CAPI *********************************************
CompilerEngine compilerEngineCreate() {
@@ -330,6 +335,10 @@ ClientParameters clientParametersUnserialize(BufferRef buffer) {
return wrap(new mlir::concretelang::ClientParameters(paramsOrError.get()));
}
ClientParameters clientParametersCopy(ClientParameters params) {
return wrap(new mlir::concretelang::ClientParameters(*unwrap(params)));
}
void clientParametersDestroy(ClientParameters params){C_STRUCT_CLEANER(params)}
/// ********** KeySet CAPI *****************************************************