Decode a serialized representation of a module data type 'mt' from string * 'str' and return a newly allocated value, or NULL if decoding failed. * * This call basically reuses the 'rdb_load' callback which module data types * implement in order to allow a module to arbitrarily serialize/de-serialize * keys, similar to how the Redis 'DUMP' and 'RESTORE' commands are implemented. * * Modules
| 5089 | * data by producing an error message and terminating the process. |
| 5090 | */ |
| 5091 | void *RM_LoadDataTypeFromString(const RedisModuleString *str, const moduleType *mt) { |
| 5092 | rio payload; |
| 5093 | RedisModuleIO io; |
| 5094 | void *ret; |
| 5095 | |
| 5096 | rioInitWithBuffer(&payload, szFromObj(str)); |
| 5097 | moduleInitIOContext(io,(moduleType *)mt,&payload,NULL); |
| 5098 | |
| 5099 | /* All RM_Save*() calls always write a version 2 compatible format, so we |
| 5100 | * need to make sure we read the same. |
| 5101 | */ |
| 5102 | io.ver = 2; |
| 5103 | ret = mt->rdb_load(&io,0); |
| 5104 | if (io.ctx) { |
| 5105 | moduleFreeContext(io.ctx); |
| 5106 | zfree(io.ctx); |
| 5107 | } |
| 5108 | return ret; |
| 5109 | } |
| 5110 | |
| 5111 | /* Encode a module data type 'mt' value 'data' into serialized form, and return it |
| 5112 | * as a newly allocated RedisModuleString. |
nothing calls this directly
no test coverage detected