MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / RM_LoadDataTypeFromString

Function RM_LoadDataTypeFromString

src/module.cpp:5091–5109  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

5089 * data by producing an error message and terminating the process.
5090 */
5091void *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.

Callers

nothing calls this directly

Calls 4

rioInitWithBufferFunction · 0.85
szFromObjFunction · 0.85
moduleFreeContextFunction · 0.85
zfreeFunction · 0.85

Tested by

no test coverage detected