rxing is a port of the zxing barcode scanning and generation library written in Java. I started the project because I couldn’t find a pure rust barcode library, though there were plenty that relied on C or C++ libraries. Start to finish the project took me about 8 months complete. This included a couple of false starts involving automated Java to Rust conversion tools, none of which worked well enough to keep using. I went into the project knowing basic Rust, and left it feeling pretty confident with the language.
One of the most surprising things to me about the project is that many people who use it actually don’t use it in rust. The majority of help requests that I have received involve using the wasm bindings on the web.
Since the initial launch there have been several releases to add new features (Micro QR support, improved QR code detection and decoding, improved maxicode detection) and fix bugs as they are found.
In a later post I’m going to talk more about the process of porting Java to Rust, and some of the pitfalls that I encountered along the way.
Here is the reddit post where I announced the project.
TLDR: The Links
- rxing (GH / crates.io): barcode scanning and generation library
- rxing-cli (GH / crates.io): a cli interface to rxing, allowing for generation and detection, it has a lot of features, which can be explored using
- rxing-wasm (GH / npm): wasm bindings for rxing which allow for a subset of functions on the web.
What is the library:
rxing is a port of the popular Java library ZXing (the name ZXing = Zebra Crossing, so rxing = crustacean crossing). rxing supports reading 16 different barcode formats, and writing 13 formats. Both 2d (QR code, Aztec, Datamatrix, Maxicode, PDF417) and 1d (coda, code 39, code 93, code 128, itf, ean 8/13, upc e/a, rss 14/expanded) are supported.
The entire library was ported by hand. I initially attempted to use some Java -> Rust conversion programs (hoping that I could just clean up the results), but those proved to be more work than simply rewriting everything. I set about porting the library manually, and spent about 8 months on the primary work of porting it.
The library is “complete” in the sense that it implements everything from the ZXing origin and includes some enhancements ported from the C++ port as well. The entire test suite has also been ported from Java.
- The original library did not include maxicode detection (it only worked if the image supplied was a perfectly centered, non-skewed, non-rotated maxicode). I have implemented rudimentary detection and rotation correction, but there is still a lot of work to be done on that.
- Maxicode generation is also in my plans.
- The “rustification” of the Java code is still in progress as well, some structures and layouts simply don’t make sense in rust.
- RSS 14 and RSS Expanded code generation is also planned.
- There are a few features which aren’t fully supported, such as “reader resets” which still need to be built out, but weren’t present in ZXing, so that went beyond the scope of the initial port.
Am I looking for PRs:
Yes, if you have improvements, enhancements, or bug fixes I’m happy to review. Tests are required for any new work.
Like ZXing, rxing is licensed under Apache 2.0.