@@ -51,7 +51,7 @@ fn from_c_str(name: &str, s: *const c_char) -> Result<String> {
5151 }
5252}
5353
54- fn to_ref < T > ( t : & * mut T ) -> Result < & mut T > {
54+ fn to_ref < ' a , T > ( t : * mut T ) -> Result < & ' a mut T > {
5555 unsafe { t. as_mut ( ) . ok_or_else ( || anyhow ! ( "null pointer" ) ) }
5656}
5757
@@ -127,15 +127,15 @@ pub extern "C" fn regorus_engine_new() -> *mut RegorusEngine {
127127///
128128#[ no_mangle]
129129pub extern "C" fn regorus_engine_clone ( engine : * mut RegorusEngine ) -> * mut RegorusEngine {
130- match to_ref ( & engine) {
130+ match to_ref ( engine) {
131131 Ok ( e) => Box :: into_raw ( Box :: new ( e. clone ( ) ) ) ,
132132 _ => std:: ptr:: null_mut ( ) ,
133133 }
134134}
135135
136136#[ no_mangle]
137137pub extern "C" fn regorus_engine_drop ( engine : * mut RegorusEngine ) {
138- if let Ok ( e) = to_ref ( & engine) {
138+ if let Ok ( e) = to_ref ( engine) {
139139 unsafe {
140140 let _ = Box :: from_raw ( std:: ptr:: from_mut ( e) ) ;
141141 }
@@ -156,7 +156,7 @@ pub extern "C" fn regorus_engine_add_policy(
156156 rego : * const c_char ,
157157) -> RegorusResult {
158158 to_regorus_string_result ( || -> Result < String > {
159- to_ref ( & engine) ?
159+ to_ref ( engine) ?
160160 . engine
161161 . add_policy ( from_c_str ( "path" , path) ?, from_c_str ( "rego" , rego) ?)
162162 } ( ) )
@@ -169,7 +169,7 @@ pub extern "C" fn regorus_engine_add_policy_from_file(
169169 path : * const c_char ,
170170) -> RegorusResult {
171171 to_regorus_string_result ( || -> Result < String > {
172- to_ref ( & engine) ?
172+ to_ref ( engine) ?
173173 . engine
174174 . add_policy_from_file ( from_c_str ( "path" , path) ?)
175175 } ( ) )
@@ -185,7 +185,7 @@ pub extern "C" fn regorus_engine_add_data_json(
185185 data : * const c_char ,
186186) -> RegorusResult {
187187 to_regorus_result ( || -> Result < ( ) > {
188- to_ref ( & engine) ?
188+ to_ref ( engine) ?
189189 . engine
190190 . add_data ( regorus:: Value :: from_json_str ( & from_c_str ( "data" , data) ?) ?)
191191 } ( ) )
@@ -197,7 +197,7 @@ pub extern "C" fn regorus_engine_add_data_json(
197197#[ no_mangle]
198198pub extern "C" fn regorus_engine_get_packages ( engine : * mut RegorusEngine ) -> RegorusResult {
199199 to_regorus_string_result ( || -> Result < String > {
200- serde_json:: to_string_pretty ( & to_ref ( & engine) ?. engine . get_packages ( ) ?)
200+ serde_json:: to_string_pretty ( & to_ref ( engine) ?. engine . get_packages ( ) ?)
201201 . map_err ( anyhow:: Error :: msg)
202202 } ( ) )
203203}
@@ -208,7 +208,7 @@ pub extern "C" fn regorus_engine_get_packages(engine: *mut RegorusEngine) -> Reg
208208#[ no_mangle]
209209pub extern "C" fn regorus_engine_get_policies ( engine : * mut RegorusEngine ) -> RegorusResult {
210210 to_regorus_string_result ( || -> Result < String > {
211- to_ref ( & engine) ?. engine . get_policies_as_json ( )
211+ to_ref ( engine) ?. engine . get_policies_as_json ( )
212212 } ( ) )
213213}
214214
@@ -219,7 +219,7 @@ pub extern "C" fn regorus_engine_add_data_from_json_file(
219219 path : * const c_char ,
220220) -> RegorusResult {
221221 to_regorus_result ( || -> Result < ( ) > {
222- to_ref ( & engine) ?
222+ to_ref ( engine) ?
223223 . engine
224224 . add_data ( regorus:: Value :: from_json_file ( from_c_str ( "path" , path) ?) ?)
225225 } ( ) )
@@ -231,7 +231,7 @@ pub extern "C" fn regorus_engine_add_data_from_json_file(
231231#[ no_mangle]
232232pub extern "C" fn regorus_engine_clear_data ( engine : * mut RegorusEngine ) -> RegorusResult {
233233 to_regorus_result ( || -> Result < ( ) > {
234- to_ref ( & engine) ?. engine . clear_data ( ) ;
234+ to_ref ( engine) ?. engine . clear_data ( ) ;
235235 Ok ( ( ) )
236236 } ( ) )
237237}
@@ -246,7 +246,7 @@ pub extern "C" fn regorus_engine_set_input_json(
246246 input : * const c_char ,
247247) -> RegorusResult {
248248 to_regorus_result ( || -> Result < ( ) > {
249- to_ref ( & engine) ?
249+ to_ref ( engine) ?
250250 . engine
251251 . set_input ( regorus:: Value :: from_json_str ( & from_c_str ( "input" , input) ?) ?) ;
252252 Ok ( ( ) )
@@ -260,7 +260,7 @@ pub extern "C" fn regorus_engine_set_input_from_json_file(
260260 path : * const c_char ,
261261) -> RegorusResult {
262262 to_regorus_result ( || -> Result < ( ) > {
263- to_ref ( & engine) ?
263+ to_ref ( engine) ?
264264 . engine
265265 . set_input ( regorus:: Value :: from_json_file ( from_c_str ( "path" , path) ?) ?) ;
266266 Ok ( ( ) )
@@ -277,7 +277,7 @@ pub extern "C" fn regorus_engine_eval_query(
277277 query : * const c_char ,
278278) -> RegorusResult {
279279 let output = || -> Result < String > {
280- let results = to_ref ( & engine) ?
280+ let results = to_ref ( engine) ?
281281 . engine
282282 . eval_query ( from_c_str ( "query" , query) ?, false ) ?;
283283 Ok ( serde_json:: to_string_pretty ( & results) ?)
@@ -302,7 +302,7 @@ pub extern "C" fn regorus_engine_eval_rule(
302302 rule : * const c_char ,
303303) -> RegorusResult {
304304 let output = || -> Result < String > {
305- to_ref ( & engine) ?
305+ to_ref ( engine) ?
306306 . engine
307307 . eval_rule ( from_c_str ( "rule" , rule) ?) ?
308308 . to_json_str ( )
@@ -328,7 +328,7 @@ pub extern "C" fn regorus_engine_set_enable_coverage(
328328 enable : bool ,
329329) -> RegorusResult {
330330 to_regorus_result ( || -> Result < ( ) > {
331- to_ref ( & engine) ?. engine . set_enable_coverage ( enable) ;
331+ to_ref ( engine) ?. engine . set_enable_coverage ( enable) ;
332332 Ok ( ( ) )
333333 } ( ) )
334334}
@@ -341,7 +341,7 @@ pub extern "C" fn regorus_engine_set_enable_coverage(
341341pub extern "C" fn regorus_engine_get_coverage_report ( engine : * mut RegorusEngine ) -> RegorusResult {
342342 let output = || -> Result < String > {
343343 Ok ( serde_json:: to_string_pretty (
344- & to_ref ( & engine) ?. engine . get_coverage_report ( ) ?,
344+ & to_ref ( engine) ?. engine . get_coverage_report ( ) ?,
345345 ) ?)
346346 } ( ) ;
347347 match output {
@@ -364,7 +364,7 @@ pub extern "C" fn regorus_engine_set_strict_builtin_errors(
364364 strict : bool ,
365365) -> RegorusResult {
366366 to_regorus_result ( || -> Result < ( ) > {
367- to_ref ( & engine) ?. engine . set_strict_builtin_errors ( strict) ;
367+ to_ref ( engine) ?. engine . set_strict_builtin_errors ( strict) ;
368368 Ok ( ( ) )
369369 } ( ) )
370370}
@@ -378,7 +378,7 @@ pub extern "C" fn regorus_engine_get_coverage_report_pretty(
378378 engine : * mut RegorusEngine ,
379379) -> RegorusResult {
380380 let output = || -> Result < String > {
381- to_ref ( & engine) ?
381+ to_ref ( engine) ?
382382 . engine
383383 . get_coverage_report ( ) ?
384384 . to_string_pretty ( )
@@ -400,7 +400,7 @@ pub extern "C" fn regorus_engine_get_coverage_report_pretty(
400400#[ cfg( feature = "coverage" ) ]
401401pub extern "C" fn regorus_engine_clear_coverage_data ( engine : * mut RegorusEngine ) -> RegorusResult {
402402 to_regorus_result ( || -> Result < ( ) > {
403- to_ref ( & engine) ?. engine . clear_coverage_data ( ) ;
403+ to_ref ( engine) ?. engine . clear_coverage_data ( ) ;
404404 Ok ( ( ) )
405405 } ( ) )
406406}
@@ -415,7 +415,7 @@ pub extern "C" fn regorus_engine_set_gather_prints(
415415 enable : bool ,
416416) -> RegorusResult {
417417 to_regorus_result ( || -> Result < ( ) > {
418- to_ref ( & engine) ?. engine . set_gather_prints ( enable) ;
418+ to_ref ( engine) ?. engine . set_gather_prints ( enable) ;
419419 Ok ( ( ) )
420420 } ( ) )
421421}
@@ -427,7 +427,7 @@ pub extern "C" fn regorus_engine_set_gather_prints(
427427pub extern "C" fn regorus_engine_take_prints ( engine : * mut RegorusEngine ) -> RegorusResult {
428428 let output = || -> Result < String > {
429429 Ok ( serde_json:: to_string_pretty (
430- & to_ref ( & engine) ?. engine . take_prints ( ) ?,
430+ & to_ref ( engine) ?. engine . take_prints ( ) ?,
431431 ) ?)
432432 } ( ) ;
433433 match output {
@@ -446,7 +446,7 @@ pub extern "C" fn regorus_engine_take_prints(engine: *mut RegorusEngine) -> Rego
446446#[ no_mangle]
447447#[ cfg( feature = "ast" ) ]
448448pub extern "C" fn regorus_engine_get_ast_as_json ( engine : * mut RegorusEngine ) -> RegorusResult {
449- let output = || -> Result < String > { to_ref ( & engine) ?. engine . get_ast_as_json ( ) } ( ) ;
449+ let output = || -> Result < String > { to_ref ( engine) ?. engine . get_ast_as_json ( ) } ( ) ;
450450 match output {
451451 Ok ( out) => RegorusResult {
452452 status : RegorusStatus :: RegorusStatusOk ,
@@ -466,7 +466,7 @@ pub extern "C" fn regorus_engine_set_rego_v0(
466466 enable : bool ,
467467) -> RegorusResult {
468468 let output = || -> Result < ( ) > {
469- to_ref ( & engine) ?. engine . set_rego_v0 ( enable) ;
469+ to_ref ( engine) ?. engine . set_rego_v0 ( enable) ;
470470 Ok ( ( ) )
471471 } ( ) ;
472472 match output {
0 commit comments