-
Notifications
You must be signed in to change notification settings - Fork 76
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
Encoding with less bytes. #60
Comments
Just wondering why you linked bincode, as it is not a dependency of message-io? Do you mean that the code from bincode could be re-used (adapted) to the project? |
Hi @Uriopass, The idea is to add this dependency and uses its variadic encoding for integers. Currently, the |
I think bincode is quite a heavy dependency for such a simple thing. I think a basic implementation (I tried writing one but it was not very pretty, might try again later) could work like this: You could also use something like the UTF-8 varlength encoding scheme using the first n |
Thanks for the hint! Of course, any other lighter library to reach the target is also valid. I just make a fast search and I found a library that does precisely this, without all the extra payload of bincode. It could be a good option: https://docs.rs/integer-encoding/3.0.2/integer_encoding/trait.VarInt.html Regarding this:
I think that a lot of messages could have more than 255 byres, be forced to use 4 bytes, instead of 2 bytes in most of the cases. |
Currently, the
FramedTcp
adapter reaches its target of "transform" TCP from stream-based to packet-based adding an offset of 4 bytes before the packet to determine its size using the encoding module (this module could be used for other adapters but currently is only used forFramedTcp
).For most cases, 4 bytes is too many bytes (most of the messages could use 1 or 2 bytes). Fortunately,
bincode
has an option to make variadic int encoding. This should be relatively easy to implement.EDIT: Other cool library to get this functionality instead
bincode
: integer_encodingThe text was updated successfully, but these errors were encountered: