Barcoders is a barcode-encoding library for the Rust programming language.
Barcoders allows you to encode valid data for a chosen symbology into a Vec<u8>
representation of the underlying binary structure. From here, you can take advantage one of optional builtin generators (for exporting to GIF, PNG, etc) or build your own.
Please note, Barcoders is under active development. Initial release is expected late November, 2015
Installation
Coming soon... I will hopefully push to Crates.io on Sunday, 22nd of November.
Current Support
The ultimate goal of Barcoders is to provide encoding support for all major (and many not-so-major) symbologies.
Symbologies
- EAN-13
- UPC-A
- JAN
- Bookland
- EAN-8
- EAN Supplementals
- EAN-2
- EAN-5
- Code39
- Two-Of-Five
- Interleaved (ITF)
- Standard (STF)
- More coming!
Generators
- ASCII
- PNG
- GIF
- JPEG
- More coming! (PostScript, SVG, etc)
Examples
Image generation
extern crate barcoders;
use *;
use *;
use File;
use Path;
let barcode = new.unwrap;
let png = PNG;
// The `encode` method returns a Vec<u8> of the binary representation of the
// generated barcode. This is useful if you want to add your own generator.
let encoded: = barcode.encode;
// Image generators save the file to the given path and return a u32 indicating
// the number of bytes written to disk.
let mut path = create.unwrap;
let bytes = png.generate.unwrap;
// Generated file ↓ ↓ ↓
ASCII generation
extern crate barcoders;
use *;
use *;
let barcode = EAN13 new.unwrap;
let encoded: = barcode.encode;
// The ASCII generator is useful for testing purposes.
let ascii = ASCII new;
ascii.generate;
assert_eq!;
Tests
Note, some of the image tests (intentionally) leave behind image files in ./target/debug that should be visually inspected for correctness.
Full suite:
$ cargo test --features="image ascii"
Encoding only:
$ cargo test