@@ -42,11 +42,14 @@ impl RedisKey {
4242 RedisKey { ctx, key_inner }
4343 }
4444
45+ /// # Panics
46+ ///
47+ /// Will panic if `RedisModule_ModuleTypeGetValue` is missing in redismodule.h
4548 pub fn get_value < T > ( & self , redis_type : & RedisType ) -> Result < Option < & T > , RedisError > {
4649 verify_type ( self . key_inner , redis_type) ?;
4750
4851 let value =
49- unsafe { raw:: RedisModule_ModuleTypeGetValue . unwrap ( ) ( self . key_inner ) as * mut T } ;
52+ unsafe { raw:: RedisModule_ModuleTypeGetValue . unwrap ( ) ( self . key_inner ) . cast :: < T > ( ) } ;
5053
5154 if value. is_null ( ) {
5255 return Ok ( None ) ;
@@ -57,6 +60,9 @@ impl RedisKey {
5760 Ok ( Some ( value) )
5861 }
5962
63+ /// # Panics
64+ ///
65+ /// Will panic if `RedisModule_KeyType` is missing in redismodule.h
6066 pub fn key_type ( & self ) -> raw:: KeyType {
6167 unsafe { raw:: RedisModule_KeyType . unwrap ( ) ( self . key_inner ) } . into ( )
6268 }
@@ -247,11 +253,17 @@ impl RedisKeyWritable {
247253 }
248254 }
249255
256+ /// # Panics
257+ ///
258+ /// Will panic if `RedisModule_DeleteKey` is missing in redismodule.h
250259 pub fn delete ( & self ) -> RedisResult {
251260 unsafe { raw:: RedisModule_DeleteKey . unwrap ( ) ( self . key_inner ) } ;
252261 REDIS_OK
253262 }
254263
264+ /// # Panics
265+ ///
266+ /// Will panic if `RedisModule_KeyType` is missing in redismodule.h
255267 pub fn key_type ( & self ) -> raw:: KeyType {
256268 unsafe { raw:: RedisModule_KeyType . unwrap ( ) ( self . key_inner ) } . into ( )
257269 }
@@ -268,13 +280,16 @@ impl RedisKeyWritable {
268280 RedisKeyWritable { ctx, key_inner }
269281 }
270282
283+ /// # Panics
284+ ///
285+ /// Will panic if `RedisModule_ModuleTypeGetValue` is missing in redismodule.h
271286 pub fn get_value < ' a , ' b , T > (
272287 & ' a self ,
273288 redis_type : & RedisType ,
274289 ) -> Result < Option < & ' b mut T > , RedisError > {
275290 verify_type ( self . key_inner , redis_type) ?;
276291 let value =
277- unsafe { raw:: RedisModule_ModuleTypeGetValue . unwrap ( ) ( self . key_inner ) as * mut T } ;
292+ unsafe { raw:: RedisModule_ModuleTypeGetValue . unwrap ( ) ( self . key_inner ) . cast :: < T > ( ) } ;
278293
279294 if value. is_null ( ) {
280295 return Ok ( None ) ;
@@ -284,9 +299,12 @@ impl RedisKeyWritable {
284299 Ok ( Some ( value) )
285300 }
286301
302+ /// # Panics
303+ ///
304+ /// Will panic if `RedisModule_ModuleTypeSetValue` is missing in redismodule.h
287305 pub fn set_value < T > ( & self , redis_type : & RedisType , value : T ) -> Result < ( ) , RedisError > {
288306 verify_type ( self . key_inner , redis_type) ?;
289- let value = Box :: into_raw ( Box :: new ( value) ) as * mut c_void ;
307+ let value = Box :: into_raw ( Box :: new ( value) ) . cast :: < c_void > ( ) ;
290308 let status: raw:: Status = unsafe {
291309 raw:: RedisModule_ModuleTypeSetValue . unwrap ( ) (
292310 self . key_inner ,
@@ -358,7 +376,7 @@ where
358376
359377 /// Provides an iterator over the multi-get results in the form of (field-name, field-value)
360378 /// pairs. The type of field-name elements is the same as that passed to the original multi-
361- /// get call, while the field-value elements may be of any type for which a RedisString `Into`
379+ /// get call, while the field-value elements may be of any type for which a ` RedisString` `Into`
362380 /// conversion is implemented.
363381 ///
364382 /// # Examples
@@ -462,6 +480,10 @@ fn to_raw_mode(mode: KeyMode) -> raw::KeyMode {
462480 }
463481}
464482
483+ /// # Panics
484+ ///
485+ /// Will panic if `RedisModule_KeyType` or `RedisModule_ModuleTypeGetType` are missing in redismodule.h
486+ #[ allow( clippy:: not_unsafe_ptr_arg_deref) ]
465487pub fn verify_type ( key_inner : * mut raw:: RedisModuleKey , redis_type : & RedisType ) -> RedisResult {
466488 let key_type: KeyType = unsafe { raw:: RedisModule_KeyType . unwrap ( ) ( key_inner) } . into ( ) ;
467489
0 commit comments