-
-
Notifications
You must be signed in to change notification settings - Fork 279
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
A specification missing #221
Comments
Hi @realcr; great question! I do have plans for releasing documentation on how bincode works internally, but not for people to use to implement decoders/encoders in other languages. This is because bincode depends precisely on your structs are laid out and how the serde serialize/deserialize impls are generated. I think you put it well in that this is mainly supposed to be used internally by Rust programs; I might go further and say that it should only be used by the same program because you must be sure that the serialization and deserialization must be implemented exactly the same. Hope that answers your question! If I were you, I'd take a look at bson, it also uses serde and has libraries in many other languages. |
Thank you for your quick reply! I have not decided yet what to do. the bincode approach was very compelling as it works nicely and results in very small messages. I think that I will use some parser like https://github.com/Geal/nom to parse the messages I'm receiving. Regarding the spec, even if bincode is not going to be used by other languages, I agree with you that it is probably a good idea to have a spec. |
@realcr: the only other recommendation that I would have for you would be to check out protobuf or captain-proto. Very fast serialization / deserialization, and I believe that the messages are quite small (they definitely don't include the field names). |
@TyOverby: Thank you! I will be sure to check those out. |
Hi! Congratulations with bin-code 👍 to the idea of providing a language-independent specification. I believe there is a particular niche for cross-language serialization, which, surprisingly, is better served by bincode than by other existing formats. This use case came up in exonum. Specifically, exonum serializes various user-defined messages to binary, and then cryptographically signs the binary data. For this use-case, it is very desirable that the serialization format is canonical: that is, that each message has exactly one valid encoding. Or, more formally So, self-describing and forwards-compatible properties of formats like protobuf, cap'n'proto, JSON or CBOR are actively harmful for this use case: if you can reorder or add fields, it's hard to get canonical property. Not that cap'n'proto supports canonicalization, but it is not an intrinsic property of the format. In contrast, there's by construction only one way to serialize the data in bincode, and this is a real unique competitive advantage of this format :) |
Is this documented somewhere? |
Something important to document, that doesn't necessarily require documenting the protocol but would likely be a part of the specification is compatibility guarantees.
It would be nice to know which of these (if any) are guaranteed to be compatible, if they have any well-defined degradation or if it is undefined. |
I'm still confused on two points worth addressing: Backward compatibility: Can I read bytes saved years or decades ago? Maintainability: Can I easily manage different versions of my structs as they change? I'm looking into other options, given these two items are not well explained in this issue. |
@cheako since 1.0 the bitstream should be stable. (pending an answer on serde-rs/serde#1756). I haven't evaluated struct changes in depth but they are very fragile at the least. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi TyOverby, thank you for the great work on this crate!
I was wondering if bincode has any written specification. I searched the repository and googled a bit but I couldn't find any written spec.
I wanted to use this crate for serializing/deserializing basic protocol network messages, but then realized that I might have difficulty writing a client in another language (Like javascript or python) to communicate with my rust server. A spec could really help with the task of writing a minimal serializer on the client side.
It is possible that bincode was written with the intent of only being used internally by Rust programs, and in that case my question is probably not relevant. What do you think?
The text was updated successfully, but these errors were encountered: