Asmod4n / mruby-simplemsgpack

mruby wrapper for msgpack (>= 1.0) / msgpack.org[mruby]
Apache License 2.0
5 stars 3 forks source link

Let MessagePack.unpack(data, &block) return number of bytes unpacked #2

Closed christopheraue closed 7 years ago

christopheraue commented 7 years ago

Reading from a stream very likely returns packed data with an incomplete object at the end. To unpack what's ready and continue to unpack the incomplete object once more data arrived one needs to know how much of the given data has been unpacked.

This PR changes the return value of MessagePack.unpack(data) if called with a block from self to the offset in data after the last complete unpack operation.

Asmod4n commented 7 years ago

Messagepack-c has a special return value if it cannot unpack the howl stream, I'll take a look at it