What is the Elixir way of decoding/parsing binary data?

Hello friends! I’m about to drop to community, under MIT licence, my library for bidirectional parse/encode communication.

Idea is you declaring shape of your binary data and set of constraints, highly dynamic ones, like dynamic length, item size, items count, dynamic variant dispatching, optionality of fields using callbacks. Callbacks may receive on request fields from current parse routine along with context options from total parse tree.

Most of the time you will work only with type conversion called ‘managed’. Most human value is possible, like number, utf8 string and so on. Does not matter actual data is utf16 and actual numbers are hidden under mask, I have abstractions to keep it complexity managed away from developer.

There is such features as receiving requested type conversion (binary version, for example) and option scoped from particular context interface.

In additional there is feature of virtual field. Virtual fields allow you declare your data as most readable and sane way independent of actual shape of binary.

Everything compiled down to elixir binary pattern matching, using graph topology I’m able to optimise most of blocks with known shape to single pattern and provide requested intermediate values only once, close as possible to usage and passing around only as function arguments, not creating any allocations or intermediate objects.

The most benefits you will get if you working with complex legacy protocol and you need flow like receive → modify → send.

It’s running in our production for few apps for half of year, and currently I’m finishing basic documentation.

Let me know if you guys are interested, I will try to finish basic docs and publish it this week!

5 Likes