-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a facility allowing manual control of the decoding #91
base: main
Are you sure you want to change the base?
Conversation
Sorry for taking so long on this. I still need to take a closer look. One thought I have is possibly moving the decoder to another package, but I have not looked into the implications of that. |
4ea5eec
to
35157ea
Compare
I removed the patterns of using an error sentinel to stop the iteration and shadowing It should pass the linter stage now. |
@oschwald Do you have any feedback on this? We have this implementation in production now. |
This would be quite good to have on my side - any feedback ? |
Before considering merging this, I'd like to see the decoder moved to a separate package. Most users of this library are not likely to use this interface, and having it in the same package as the reader is likely to cause confusion. Once that is done, I think I would be willing to accept a PR as long as the documentation made it clear that the API was experimental and subject to change. I haven't had a need for this API myself and haven't yet had the opportunity to use it. |
@oschwald The decoder relies on the internal |
This PR adds a facility allowing full manual control of the decoding process.
While we are aware that the experimental
deserializer
interface exists, it is quite painful to use as it doesn't let the caller control the sequence of operations.The implementation is centered around a
Decoder
object, which allows decoding ONE value at a particular offset.The API for scalar values is straightforward:
For maps and slices, the API iterates over the items and provides a specific decoder for the value:
The implementation follows pointers automatically, and keeps track of the offset of the "next" value as soon as it is known, which facilitate the iteration of maps and slices. (For pointers, the "next" value is the value right after the pointer, for maps and slices it is the value right after the next item.)