Hello everyone ![]()
Today I want to tell you about new version of Rpmfile library. Rpmfile is a library for reading metadata from RPM packages. Originally Rpmfile’s parser (reader) used Angstrom for parsing. And in the new release added new modern Eio-based reader.
Globally, the project is now split into four packages: rpmfile, which contains signatures and implementation-independent functions, rpmfile-unix with the original Angstrom parser, and rpmfile-eio (with rpmfile-cli) written using Eio.
My experience porting to Eio
Eio is a fantastic effect-based I/O library for a more modern age in multicore OCaml. I think it takes the best ideas from the ecosystem. So built-in Buf_read and Buf_write modules implement ideas from Angstrom and Faraday libraries. Almost API one-to-one, allowing porting via copy-paste.
But, of course, not everything is so perfect. Unlike the Angstrom.parse_ function, the Buf_read.parse function thinks I want to read a whole stream to end of input.
A snippet of the source code:
let parse ?initial_size ~max_size p flow =
let buf = of_flow flow ?initial_size ~max_size in
format_errors (p <* end_of_input) buf
(* ^^^^^^^^^^^^^^^
0_0 nice (not) *)
So I had to rewrite this function myself in a form similar to Angstrom.Consume.Prefix.
Is it a signed or unsigned integer?
BE.uint16 and other similar functions are signed int even though they have the prefix u in the name for some reason.
And a few other differences
Angstrom.advanceisskipAngstrom.posisconsumed_bytes
P.S.
Thanks for your attention!