@@ -31,6 +31,11 @@ impl<'root> StringCallReply<'root> {
3131 } ;
3232 unsafe { slice:: from_raw_parts ( reply_string, len) }
3333 }
34+
35+ /// Return the raw pointer to the underlying [RedisModuleCallReply].
36+ pub fn get_raw ( & self ) -> * mut RedisModuleCallReply {
37+ self . reply . as_ptr ( )
38+ }
3439}
3540
3641impl < ' root > Drop for StringCallReply < ' root > {
@@ -77,6 +82,11 @@ impl<'root> ErrorCallReply<'root> {
7782 } ;
7883 unsafe { slice:: from_raw_parts ( reply_string, len) }
7984 }
85+
86+ /// Return the raw pointer to the underlying [RedisModuleCallReply].
87+ pub fn get_raw ( & self ) -> * mut RedisModuleCallReply {
88+ self . reply . as_ptr ( )
89+ }
8090}
8191
8292impl < ' root > Drop for ErrorCallReply < ' root > {
@@ -150,6 +160,11 @@ impl<'root> I64CallReply<'root> {
150160 pub fn to_i64 ( & self ) -> i64 {
151161 call_reply_integer ( self . reply . as_ptr ( ) )
152162 }
163+
164+ /// Return the raw pointer to the underlying [RedisModuleCallReply].
165+ pub fn get_raw ( & self ) -> * mut RedisModuleCallReply {
166+ self . reply . as_ptr ( )
167+ }
153168}
154169
155170impl < ' root > Drop for I64CallReply < ' root > {
@@ -204,6 +219,11 @@ impl<'root> ArrayCallReply<'root> {
204219 pub fn len ( & self ) -> usize {
205220 call_reply_length ( self . reply . as_ptr ( ) )
206221 }
222+
223+ /// Return the raw pointer to the underlying [RedisModuleCallReply].
224+ pub fn get_raw ( & self ) -> * mut RedisModuleCallReply {
225+ self . reply . as_ptr ( )
226+ }
207227}
208228
209229pub struct ArrayCallReplyIterator < ' root , ' curr > {
@@ -254,6 +274,13 @@ pub struct NullCallReply<'root> {
254274 _dummy : PhantomData < & ' root ( ) > ,
255275}
256276
277+ impl < ' root > NullCallReply < ' root > {
278+ /// Return the raw pointer to the underlying [RedisModuleCallReply].
279+ pub fn get_raw ( & self ) -> * mut RedisModuleCallReply {
280+ self . reply . as_ptr ( )
281+ }
282+ }
283+
257284impl < ' root > Drop for NullCallReply < ' root > {
258285 fn drop ( & mut self ) {
259286 free_call_reply ( self . reply . as_ptr ( ) ) ;
@@ -303,6 +330,11 @@ impl<'root> MapCallReply<'root> {
303330 pub fn len ( & self ) -> usize {
304331 call_reply_length ( self . reply . as_ptr ( ) )
305332 }
333+
334+ /// Return the raw pointer to the underlying [RedisModuleCallReply].
335+ pub fn get_raw ( & self ) -> * mut RedisModuleCallReply {
336+ self . reply . as_ptr ( )
337+ }
306338}
307339
308340pub struct MapCallReplyIterator < ' root , ' curr > {
@@ -384,6 +416,11 @@ impl<'root> SetCallReply<'root> {
384416 pub fn len ( & self ) -> usize {
385417 call_reply_length ( self . reply . as_ptr ( ) )
386418 }
419+
420+ /// Return the raw pointer to the underlying [RedisModuleCallReply].
421+ pub fn get_raw ( & self ) -> * mut RedisModuleCallReply {
422+ self . reply . as_ptr ( )
423+ }
387424}
388425
389426pub struct SetCallReplyIterator < ' root , ' curr > {
@@ -445,6 +482,11 @@ impl<'root> BoolCallReply<'root> {
445482 pub fn to_bool ( & self ) -> bool {
446483 call_reply_bool ( self . reply . as_ptr ( ) )
447484 }
485+
486+ /// Return the raw pointer to the underlying [RedisModuleCallReply].
487+ pub fn get_raw ( & self ) -> * mut RedisModuleCallReply {
488+ self . reply . as_ptr ( )
489+ }
448490}
449491
450492impl < ' root > Drop for BoolCallReply < ' root > {
@@ -478,6 +520,11 @@ impl<'root> DoubleCallReply<'root> {
478520 pub fn to_double ( & self ) -> f64 {
479521 call_reply_double ( self . reply . as_ptr ( ) )
480522 }
523+
524+ /// Return the raw pointer to the underlying [RedisModuleCallReply].
525+ pub fn get_raw ( & self ) -> * mut RedisModuleCallReply {
526+ self . reply . as_ptr ( )
527+ }
481528}
482529
483530impl < ' root > Drop for DoubleCallReply < ' root > {
@@ -512,6 +559,11 @@ impl<'root> BigNumberCallReply<'root> {
512559 pub fn to_string ( & self ) -> Option < String > {
513560 call_reply_big_number ( self . reply . as_ptr ( ) )
514561 }
562+
563+ /// Return the raw pointer to the underlying [RedisModuleCallReply].
564+ pub fn get_raw ( & self ) -> * mut RedisModuleCallReply {
565+ self . reply . as_ptr ( )
566+ }
515567}
516568
517569impl < ' root > Drop for BigNumberCallReply < ' root > {
@@ -540,6 +592,13 @@ pub struct VerbatimStringCallReply<'root> {
540592 _dummy : PhantomData < & ' root ( ) > ,
541593}
542594
595+ impl < ' root > VerbatimStringCallReply < ' root > {
596+ /// Return the raw pointer to the underlying [RedisModuleCallReply].
597+ pub fn get_raw ( & self ) -> * mut RedisModuleCallReply {
598+ self . reply . as_ptr ( )
599+ }
600+ }
601+
543602/// RESP3 state that the verbatim string format must be of length 3.
544603const VERBATIM_FORMAT_LENGTH : usize = 3 ;
545604/// The string format of a verbatim string ([VerbatimStringCallReply]).
@@ -639,6 +698,25 @@ pub enum CallReply<'root> {
639698 VerbatimString ( VerbatimStringCallReply < ' root > ) ,
640699}
641700
701+ impl < ' root > CallReply < ' root > {
702+ /// Return the raw pointer to the underlying [RedisModuleCallReply].
703+ pub fn get_raw ( & self ) -> * mut RedisModuleCallReply {
704+ match self {
705+ CallReply :: Unknown => std:: ptr:: null_mut ( ) ,
706+ CallReply :: I64 ( inner) => inner. get_raw ( ) ,
707+ CallReply :: String ( inner) => inner. get_raw ( ) ,
708+ CallReply :: Array ( inner) => inner. get_raw ( ) ,
709+ CallReply :: Null ( inner) => inner. get_raw ( ) ,
710+ CallReply :: Map ( inner) => inner. get_raw ( ) ,
711+ CallReply :: Set ( inner) => inner. get_raw ( ) ,
712+ CallReply :: Bool ( inner) => inner. get_raw ( ) ,
713+ CallReply :: Double ( inner) => inner. get_raw ( ) ,
714+ CallReply :: BigNumber ( inner) => inner. get_raw ( ) ,
715+ CallReply :: VerbatimString ( inner) => inner. get_raw ( ) ,
716+ }
717+ }
718+ }
719+
642720/// Send implementation to [CallReply].
643721/// We need to implements this trait because [CallReply] hold
644722/// raw pointers to C data which does not auto implement the [Send] trait.
0 commit comments