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

Add hooks to the encoder to allow encoding tags #4

Merged
merged 1 commit into from
Feb 16, 2016

Conversation

mildred
Copy link

@mildred mildred commented Feb 10, 2016

There is a few things here:

  • If a type implements a marshaller interface, use this interface to marshall the value
  • Make the tag type implement the marshaller interface
  • Export Encoding functions to allow access encoding small data from outside of this package

This is necessary to encode IPLD using tags as defined in ipfs/specs#61. The last item is useful to implement the marshaller interface and to generate the expected byte slice in unit tests.

// result to avoid a memory allocation. It should be a slice with a sufficient
// capacity.
func EncodeInt(tag byte, v uint64, buf []byte) []byte {
if v <= 23 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should be a switch statement

@mildred
Copy link
Author

mildred commented Feb 10, 2016

updated to the switch statement

@whyrusleeping
Copy link
Owner

alright cool, LGTM

whyrusleeping added a commit that referenced this pull request Feb 16, 2016
Add hooks to the encoder to allow encoding tags
@whyrusleeping whyrusleeping merged commit 4e3c199 into whyrusleeping:master Feb 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants