@@ -131,6 +131,22 @@ pub fn json_api_get_json<M: Manager>(
131
131
create_rmstring ( ctx, & res, str)
132
132
}
133
133
134
+ pub fn json_api_get_json_from_iter < M : Manager > (
135
+ _: M ,
136
+ iter : * mut c_void ,
137
+ ctx : * mut rawmod:: RedisModuleCtx ,
138
+ str : * mut * mut rawmod:: RedisModuleString ,
139
+ ) -> c_int {
140
+ let iter = unsafe { & * ( iter. cast :: < ResultsIterator < M :: V > > ( ) ) } ;
141
+ if iter. pos >= iter. results . len ( ) {
142
+ Status :: Err as c_int
143
+ } else {
144
+ let res = KeyValue :: < M :: V > :: serialize_object ( & iter. results , None , None , None ) ;
145
+ create_rmstring ( ctx, & res, str) ;
146
+ Status :: Ok as c_int
147
+ }
148
+ }
149
+
134
150
#[ allow( clippy:: not_unsafe_ptr_arg_deref) ]
135
151
pub fn json_api_get_int < M : Manager > ( _: M , json : * const c_void , val : * mut c_longlong ) -> c_int {
136
152
let json = unsafe { & * ( json. cast :: < M :: V > ( ) ) } ;
@@ -393,6 +409,17 @@ macro_rules! redis_json_module_export_shared_api {
393
409
)
394
410
}
395
411
412
+ #[ no_mangle]
413
+ pub extern "C" fn JSONAPI_getJSONFromIter ( iter: * mut c_void,
414
+ ctx: * mut rawmod:: RedisModuleCtx ,
415
+ str : * mut * mut rawmod:: RedisModuleString , ) -> c_int {
416
+ run_on_manager!(
417
+ pre_command: ||$pre_command_function_expr( & get_llapi_ctx( ) , & Vec :: new( ) ) ,
418
+ get_mngr: $get_manager_expr,
419
+ run: |mngr|{ json_api_get_json_from_iter( mngr, iter, ctx, str ) } ,
420
+ )
421
+ }
422
+
396
423
#[ no_mangle]
397
424
pub extern "C" fn JSONAPI_isJSON ( key: * mut rawmod:: RedisModuleKey ) -> c_int {
398
425
run_on_manager!(
@@ -475,6 +502,7 @@ macro_rules! redis_json_module_export_shared_api {
475
502
pathFree: JSONAPI_pathFree ,
476
503
pathIsSingle: JSONAPI_pathIsSingle ,
477
504
pathHasDefinedOrder: JSONAPI_pathHasDefinedOrder ,
505
+ getJSONFromIter: JSONAPI_getJSONFromIter ,
478
506
} ;
479
507
480
508
#[ repr( C ) ]
@@ -514,6 +542,7 @@ macro_rules! redis_json_module_export_shared_api {
514
542
pub pathFree: extern "C" fn ( json_path: * mut c_void) ,
515
543
pub pathIsSingle: extern "C" fn ( json_path: * const c_void) -> c_int,
516
544
pub pathHasDefinedOrder: extern "C" fn ( json_path: * const c_void) -> c_int,
545
+ pub getJSONFromIter: extern "C" fn ( iter: * mut c_void, ctx: * mut rawmod:: RedisModuleCtx , str : * mut * mut rawmod:: RedisModuleString , ) -> c_int,
517
546
}
518
547
} ;
519
548
}
0 commit comments