@@ -6,6 +6,7 @@ use std::os::raw::{c_int, c_void};
66use crate :: raw;
77
88pub struct RedisType {
9+ name : & ' static str ,
910 pub raw_type : RefCell < * mut raw:: RedisModuleType > ,
1011}
1112
@@ -14,24 +15,24 @@ pub struct RedisType {
1415unsafe impl Sync for RedisType { }
1516
1617impl RedisType {
17- pub const fn new ( ) -> Self {
18+ pub const fn new ( name : & ' static str ) -> Self {
1819 RedisType {
20+ name,
1921 raw_type : RefCell :: new ( ptr:: null_mut ( ) ) ,
2022 }
2123 }
2224
2325 pub fn create_data_type (
2426 & self ,
2527 ctx : * mut raw:: RedisModuleCtx ,
26- name : & str ,
2728 ) -> Result < ( ) , & str > {
28- if name. len ( ) != 9 {
29+ if self . name . len ( ) != 9 {
2930 let msg = "Redis requires the length of native type names to be exactly 9 characters" ;
30- redis_log ( ctx, format ! ( "{}, name is: '{}'" , msg, name) . as_str ( ) ) ;
31+ redis_log ( ctx, format ! ( "{}, name is: '{}'" , msg, self . name) . as_str ( ) ) ;
3132 return Err ( msg) ;
3233 }
3334
34- let type_name = CString :: new ( name) . unwrap ( ) ;
35+ let type_name = CString :: new ( self . name ) . unwrap ( ) ;
3536
3637 let mut type_methods = raw:: RedisModuleTypeMethods {
3738 version : raw:: REDISMODULE_TYPE_METHOD_VERSION as u64 ,
@@ -62,7 +63,7 @@ impl RedisType {
6263
6364 * self . raw_type . borrow_mut ( ) = redis_type;
6465
65- redis_log ( ctx, format ! ( "Created new data type '{}'" , name) . as_str ( ) ) ;
66+ redis_log ( ctx, format ! ( "Created new data type '{}'" , self . name) . as_str ( ) ) ;
6667
6768 Ok ( ( ) )
6869 }
0 commit comments