Skip to content
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

Support encoding.[BinaryMarshaler,BinaryUnmarshaler]? #5

Closed
Yawning opened this issue Oct 3, 2019 · 3 comments
Closed

Support encoding.[BinaryMarshaler,BinaryUnmarshaler]? #5

Yawning opened this issue Oct 3, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@Yawning
Copy link

Yawning commented Oct 3, 2019

Is there any interest in supporting special handling for types that know how to serialize themselves into a binary representation? encoding/json supports calling a given object's encoding.TextMarshaler and encoding.TextUnmarshaler implementations if provided, as does the go-codec library.

For CBOR the binary equivalents probably make more sense. I've started poking at this in a local branch, and while the encoding side was straightforward to add, the decoding side is a bit more involved due to parseInterface.

@fxamacker
Copy link
Owner

Thanks for the suggestion. I'm looking into it.

You're right that encoding is easier than decoding for this.

@Yawning
Copy link
Author

Yawning commented Oct 7, 2019

The commit from 3 days ago appears to work. I'm still in the progress of migrating the codebase I wanted this for, but all of the issues encountered so far are "the code is dependent on how the old library did certain things".

Thanks!

@fxamacker
Copy link
Owner

Just published release v1.1.0 with this feature. It passed 10+ hours of fuzzing.

@fxamacker fxamacker added the enhancement New feature or request label Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants