@@ -8,6 +8,8 @@ use std::{
8
8
os:: raw:: { c_char, c_void} ,
9
9
} ;
10
10
11
+ use std:: marker:: PhantomData ;
12
+
11
13
use crate :: commands:: KeyValue ;
12
14
use jsonpath_lib:: select:: select_value:: { SelectValue , SelectValueType } ;
13
15
use jsonpath_lib:: select:: Selector ;
@@ -86,7 +88,13 @@ pub extern "C" fn JSONAPI_openKey(
86
88
let bytes = slice:: from_raw_parts ( bytes as * const u8 , len) ;
87
89
String :: from_utf8_lossy ( bytes) . into_owned ( )
88
90
} ;
89
- json_api_open_key_internal ( RedisJsonKeyManager , ctx, & key) as * mut c_void
91
+ json_api_open_key_internal (
92
+ RedisJsonKeyManager {
93
+ phantom : PhantomData ,
94
+ } ,
95
+ ctx,
96
+ & key,
97
+ ) as * mut c_void
90
98
}
91
99
92
100
#[ no_mangle]
@@ -95,7 +103,13 @@ pub extern "C" fn JSONAPI_openKeyFromStr(
95
103
path : * const c_char ,
96
104
) -> * mut c_void {
97
105
let key = unsafe { CStr :: from_ptr ( path) . to_str ( ) . unwrap ( ) } ;
98
- json_api_open_key_internal ( RedisJsonKeyManager , ctx, & key) as * mut c_void
106
+ json_api_open_key_internal (
107
+ RedisJsonKeyManager {
108
+ phantom : PhantomData ,
109
+ } ,
110
+ ctx,
111
+ & key,
112
+ ) as * mut c_void
99
113
}
100
114
101
115
fn json_api_get_at < M : Manager > ( _: M , json : * const c_void , index : size_t ) -> * const c_void {
@@ -111,7 +125,13 @@ fn json_api_get_at<M: Manager>(_: M, json: *const c_void, index: size_t) -> *con
111
125
112
126
#[ no_mangle]
113
127
pub extern "C" fn JSONAPI_getAt ( json : * const c_void , index : size_t ) -> * const c_void {
114
- json_api_get_at ( RedisJsonKeyManager , json, index)
128
+ json_api_get_at (
129
+ RedisJsonKeyManager {
130
+ phantom : PhantomData ,
131
+ } ,
132
+ json,
133
+ index,
134
+ )
115
135
}
116
136
117
137
fn json_api_get_len < M : Manager > ( _: M , json : * const c_void , count : * mut libc:: size_t ) -> c_int {
@@ -133,7 +153,13 @@ fn json_api_get_len<M: Manager>(_: M, json: *const c_void, count: *mut libc::siz
133
153
134
154
#[ no_mangle]
135
155
pub extern "C" fn JSONAPI_getLen ( json : * const c_void , count : * mut size_t ) -> c_int {
136
- json_api_get_len ( RedisJsonKeyManager , json, count)
156
+ json_api_get_len (
157
+ RedisJsonKeyManager {
158
+ phantom : PhantomData ,
159
+ } ,
160
+ json,
161
+ count,
162
+ )
137
163
}
138
164
139
165
fn json_api_get_type < M : Manager > ( _: M , json : * const c_void ) -> c_int {
@@ -142,7 +168,12 @@ fn json_api_get_type<M: Manager>(_: M, json: *const c_void) -> c_int {
142
168
143
169
#[ no_mangle]
144
170
pub extern "C" fn JSONAPI_getType ( json : * const c_void ) -> c_int {
145
- json_api_get_type ( RedisJsonKeyManager , json)
171
+ json_api_get_type (
172
+ RedisJsonKeyManager {
173
+ phantom : PhantomData ,
174
+ } ,
175
+ json,
176
+ )
146
177
}
147
178
148
179
fn json_api_get_string < M : Manager > (
@@ -168,7 +199,14 @@ pub extern "C" fn JSONAPI_getString(
168
199
str : * mut * const c_char ,
169
200
len : * mut size_t ,
170
201
) -> c_int {
171
- json_api_get_string ( RedisJsonKeyManager , json, str, len)
202
+ json_api_get_string (
203
+ RedisJsonKeyManager {
204
+ phantom : PhantomData ,
205
+ } ,
206
+ json,
207
+ str,
208
+ len,
209
+ )
172
210
}
173
211
174
212
fn json_api_get_json < M : Manager > (
@@ -188,7 +226,14 @@ pub extern "C" fn JSONAPI_getJSON(
188
226
ctx : * mut rawmod:: RedisModuleCtx ,
189
227
str : * mut * mut rawmod:: RedisModuleString ,
190
228
) -> c_int {
191
- json_api_get_json ( RedisJsonKeyManager , json, ctx, str)
229
+ json_api_get_json (
230
+ RedisJsonKeyManager {
231
+ phantom : PhantomData ,
232
+ } ,
233
+ json,
234
+ ctx,
235
+ str,
236
+ )
192
237
}
193
238
194
239
#[ no_mangle]
@@ -212,7 +257,13 @@ fn json_api_get_int<M: Manager>(_: M, json: *const c_void, val: *mut c_long) ->
212
257
213
258
#[ no_mangle]
214
259
pub extern "C" fn JSONAPI_getInt ( json : * const c_void , val : * mut c_long ) -> c_int {
215
- json_api_get_int ( RedisJsonKeyManager , json, val)
260
+ json_api_get_int (
261
+ RedisJsonKeyManager {
262
+ phantom : PhantomData ,
263
+ } ,
264
+ json,
265
+ val,
266
+ )
216
267
}
217
268
218
269
fn json_api_get_double < M : Manager > ( _: M , json : * const c_void , val : * mut c_double ) -> c_int {
@@ -228,7 +279,13 @@ fn json_api_get_double<M: Manager>(_: M, json: *const c_void, val: *mut c_double
228
279
229
280
#[ no_mangle]
230
281
pub extern "C" fn JSONAPI_getDouble ( json : * const c_void , val : * mut c_double ) -> c_int {
231
- json_api_get_double ( RedisJsonKeyManager , json, val)
282
+ json_api_get_double (
283
+ RedisJsonKeyManager {
284
+ phantom : PhantomData ,
285
+ } ,
286
+ json,
287
+ val,
288
+ )
232
289
}
233
290
234
291
fn json_api_get_boolean < M : Manager > ( _: M , json : * const c_void , val : * mut c_int ) -> c_int {
@@ -244,7 +301,13 @@ fn json_api_get_boolean<M: Manager>(_: M, json: *const c_void, val: *mut c_int)
244
301
245
302
#[ no_mangle]
246
303
pub extern "C" fn JSONAPI_getBoolean ( json : * const c_void , val : * mut c_int ) -> c_int {
247
- json_api_get_boolean ( RedisJsonKeyManager , json, val)
304
+ json_api_get_boolean (
305
+ RedisJsonKeyManager {
306
+ phantom : PhantomData ,
307
+ } ,
308
+ json,
309
+ val,
310
+ )
248
311
}
249
312
250
313
//---------------------------------------------------------------------------------------------
@@ -334,22 +397,43 @@ pub fn json_api_get<M: Manager>(_: M, val: *const c_void, path: *const c_char) -
334
397
335
398
#[ no_mangle]
336
399
pub extern "C" fn JSONAPI_get ( key : * const c_void , path : * const c_char ) -> * const c_void {
337
- json_api_get ( RedisJsonKeyManager , key, path)
400
+ json_api_get (
401
+ RedisJsonKeyManager {
402
+ phantom : PhantomData ,
403
+ } ,
404
+ key,
405
+ path,
406
+ )
338
407
}
339
408
340
409
#[ no_mangle]
341
410
pub extern "C" fn JSONAPI_len ( iter : * const c_void ) -> size_t {
342
- json_api_len ( RedisJsonKeyManager , iter)
411
+ json_api_len (
412
+ RedisJsonKeyManager {
413
+ phantom : PhantomData ,
414
+ } ,
415
+ iter,
416
+ )
343
417
}
344
418
345
419
#[ no_mangle]
346
420
pub extern "C" fn JSONAPI_freeIter ( iter : * mut c_void ) {
347
- json_api_free_iter ( RedisJsonKeyManager , iter)
421
+ json_api_free_iter (
422
+ RedisJsonKeyManager {
423
+ phantom : PhantomData ,
424
+ } ,
425
+ iter,
426
+ )
348
427
}
349
428
350
429
#[ no_mangle]
351
430
pub extern "C" fn JSONAPI_next ( iter : * mut c_void ) -> * const c_void {
352
- json_api_next ( RedisJsonKeyManager , iter)
431
+ json_api_next (
432
+ RedisJsonKeyManager {
433
+ phantom : PhantomData ,
434
+ } ,
435
+ iter,
436
+ )
353
437
}
354
438
355
439
static REDISJSON_GETAPI : & str = concat ! ( "RedisJSON_V1" , "\0 " ) ;
0 commit comments