| Crates.io | ean-rs |
| lib.rs | ean-rs |
| version | 0.2.2 |
| created_at | 2025-01-01 17:38:46.954391+00 |
| updated_at | 2025-01-26 17:06:40.420065+00 |
| description | A Rust library for generating and validating EAN barcodes. |
| homepage | https://github.com/Gegelascience/ean-rs |
| repository | https://github.com/Gegelascience/ean-rs |
| max_upload_size | |
| id | 1500944 |
| size | 31,274 |
EAN-RS is a Rust library for handling European Article Numbers (EAN). This library provides functionality to validate and to render EAN codes.
Add this to your Cargo.toml:
[dependencies]
ean-rs = "0.1.0"
Here is a simple example of how to check if a string is an EAN:
extern crate ean_rs;
use ean_rs::is_correct_ean;
fn main() {
let possible_ean13 = "3666154117284";
println!("Is valid: {}", is_correct_ean(possible_ean13));
}
Show it on terminal
extern crate ean_rs;
use ean_rs::show_on_terminal;
fn main() {
let ean13 = "3666154117284";
show_on_terminal(ean13);
}
If you want to generate EAN on svg file:
extern crate ean_rs;
use ean_rs::save_as_svg;
fn main() {
let ean13 = "3666154117284";
save_as_svg(ean13,"path/to/svg/file");
}
If you want to generate EAN on png file:
extern crate ean_rs;
use ean_rs::save_as_png;
fn main() {
let ean13 = "3666154117284";
// simple png
save_as_png(ean13,"path/to/png/file",None);
// define specific dimensions
let config_png = ean_rs::PngConfig::Simple(ean_rs::SimplePngConfig
{
height_barcode: 200,
border_size: 50
});
save_as_png(ean13,"path/to/png/file2",Some(config_png));
}
Contributions are welcome! Please open an issue or submit a pull request.
MIT