September 27, 2014 std.container.Array support in msgpack | ||||
---|---|---|---|---|
| ||||
I'm trying to figure out how to add raw bytes the packed stream in msgpack-d. My current try is import std.stdio; import std.conv: to; import std.container: Array; import msgpack; static void stringArrayPackHandler(E)(ref Packer p, ref Array!E x) { // p.put(192); /* p.packArray(x); */ foreach (e; x) p.pack(e); } unittest { registerPackHandler!(Array!string, stringArrayPackHandler); Array!string x = ["x", "y"]; writeln(x.pack); writeln(["x", "y"].pack); } which outputs [161, 120, 161, 121] [146, 161, 120, 161, 121] How do I add the leading byte 146? |
September 28, 2014 Re: std.container.Array support in msgpack | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nordlöw | On Saturday, 27 September 2014 at 21:24:14 UTC, Nordlöw wrote:
> How do I add the leading byte 146?
Update: This is achieved by calling stream_.put() which is only allowed in members of PackerImpl.
|
Copyright © 1999-2021 by the D Language Foundation