DecodeResult d; d = decode("+OK\r\n ".representation); auto v = d.value; auto r = d.rest; assert(v._type == ValueType.String); assert(v._svar == "OK"); assert(r == " ".representation); d = decode("-ERROR\r\ngarbage\r\n".representation); v = d.value; r = d.rest; assert(v._type == ValueType.Error); assert(v._svar == "ERROR"); assert(r == "garbage\r\n".representation); d = decode(":100\r\n".representation); v = d.value; r = d.rest; assert(v._type == ValueType.Integer); assert(v._ivar == 100); assert(r == "".representation); d = decode("$8\r\nfoobar\r\n\r\n:41\r\n".representation); v = d.value; r = d.rest; assert(v._svar == "foobar\r\n", format("<%s>", v._svar)); assert(r == ":41\r\n".representation); assert(v._type == ValueType.BulkString); d = decode("*3\r\n:1\r\n:2\r\n$6\r\nfoobar\r\nxyz".representation); v = d.value; r = d.rest; assert(v._type == ValueType.List); assert(r == "xyz".representation);
deserialize from byte array