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

Expand UserDefined to include Subtype as defined in the BSON spec #24

Open
antarestrader opened this issue Apr 30, 2020 · 3 comments
Open

Comments

@antarestrader
Copy link

Proposal

In the Notes section of the BSON spec the seventh bullet described BinData. The third sub-bullet describes the user-defined type, "\x80-\xFF "User defined" subtypes. The binary data can be anything."

Our implementation limits this to only 0x80 and throws and error on other subtypes.

I propose that the UserDefined type be redefined to include a Word8 subtype field and that accompanying changes be made to the binary get and put functions.

data UserDefined = UserDefined Word8 ByteString

Use Case

The BSON format while more compact than JSON is still a rather verbose document particularly with the way it encodes arrays. I would like to leverage the UserDefined binary part of the spec to store packed vectors of data. Using the subtype field would allow me to identify what was in the packed date without having to use a separate field of tag.

@antarestrader
Copy link
Author

I will create a pull request for this, but as it is a breaking change to the API, I would like to hear from the maintainer before doing so.

@VictorDenisov
Copy link
Member

Looking into it. I'll get back to you.

@VictorDenisov
Copy link
Member

Sorry for the delay. It looks like the right thing to do. We will bump the major version. Go ahead with the PR.

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

No branches or pull requests

2 participants