StructuredIO, an Elixir API for consuming structured input streams
Last month I published a new Hex package called StructuredIO. This week the package passed a v1.0 milestone. StructuredIO is a library for Elixir and Erlang applications. What problem does it solve? In a nutshell, it simplifies working with structured input (such as markup or binary data) that streams from another process or computer. In such situations your application needs to tolerate input arriving piecemeal rather than in complete, well-formed data elements. Input fragments may even split multibyte characters and thereby cause encoding errors. How do you tame this incidental complexity so that your application can just focus on using data elements instead of the error-prone tedium of reassembling them from fragments? StructuredIO can help. There are two main features of this library.
1. It provides a stateful process with a writer function for writing binary data. (If it sounds to you like the IO module that is part of the Elixir standard library, you’re right.)
2. It provides a variety of reader functions for conditional reading according to a specified data structure. If a complete data structure has not (yet) been written to the process, nothing is read.
The combination of these two features makes it easy for your application to allow data to trickle into a StructuredIO process, and to consume data elements only as each arrives in its entirety. You’ll find detailed examples in the project’s readme as well as in the project’s API reference. §