You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MessagePack allows binary blobs composed of several valid MessagePack objects concatenated. This is the case of the official MessagePack test data for instance (https://github.com/msgpack/msgpack/tree/master/test).
To support this kind of data you need an interface that:
returns the first object of the blob and the byte offset where the decoding stopped,
(optionally) allows you to specify an offset where the decoding should start.
An advantage of implementing this is that it would make it possible to use the "official" test data to test this module.
cmsgpack.unpack() works like now with one argument, returning just the decoded object, and starting at index 0.
If a second argument is passed, it is used to start the decoding at the specified byte. Also two values are returned instead of one, that is the decoded object, and the offset at which the decoding ended (offset of next object).
Also, no error is returned in this "two arguments" mode if not all the string is consumed of course.
This makes the API for the obvious case, obvious. The more complex API will impact only more demanding users.
This API would work. I do the opposite for return values (offset, object) and I return nil in the offset if the decoding failed (which I use for error checking) but that's a matter of style. In the context of Redis your ordering is simpler.
Activity
antirez commentedon Feb 20, 2012
I like that, thanks.
that's the idea for the API change:
This makes the API for the obvious case, obvious. The more complex API will impact only more demanding users.
Thanks for the suggestion,
Salvatore
catwell commentedon Feb 20, 2012
This API would work. I do the opposite for return values (offset, object) and I return nil in the offset if the decoding failed (which I use for error checking) but that's a matter of style. In the context of Redis your ordering is simpler.
Add fine-grained control of unpacking objects
Bump to version 0.4.0
Bump to version 0.4.0
Bump to version 0.4.0
Bump to version 0.4.0
Bump to version 0.4.0
Bump to version 0.4.0
Bump to version 0.4.0
Bump to version 0.4.0
Bump to version 0.4.0
Bump to version 0.4.0