Crates.io | qr_code |
lib.rs | qr_code |
version | 2.0.0 |
source | src |
created_at | 2020-10-10 11:51:49.38536 |
updated_at | 2023-05-30 18:25:36.95041 |
description | QR code encoder in Rust, support structured append (data in multiple qrcodes) |
homepage | |
repository | https://github.com/RCasatta/qr_code |
max_upload_size | |
id | 297984 |
size | 331,951 |
QR code encoder and decoder [*] in Rust. Documentation.
This lib forked https://docs.rs/qrcode mainly because of lack of support to structured QR code (multiple QR codes) even if the minimal change required has been pushed https://github.com/kennytm/qrcode-rust/pull/44
Moreover dependencies image
, checked_int_cast
and module render
has been removed with a view to simplicity.
Decoder part is based on https://docs.rs/rqrr/0.3.0/rqrr/ without the image detection part and is not intended for scanning QR codes from camera.
Decoder is included only for testing purpose, so that depending libraries could run round trip during tests.
requires bmp
feature
let qr_code = qr_code::QrCode::new(b"Hello").unwrap();
let bmp = qr_code.to_bmp();
bmp.write(std::fs::File::create("test.bmp").unwrap()).unwrap();
Generate this image:
Looks small?
Many context supports rescaling mode specific for pixelated images, for example in html image-rendering: pixelated;
As an alternative see method Bmp::mul
and Bmp::add_whitespace
let qr_code = qr_code::QrCode::new(b"Hello").unwrap();
println!("{}", qr_code.to_string(false, 3));
Generates this output (looks better in terminal):
█▀▀▀▀▀█ ▀▀▀█ █▀▀▀▀▀█
█ ███ █ █ █ ▀ █ ███ █
█ ▀▀▀ █ ██ ▄▀ █ ▀▀▀ █
▀▀▀▀▀▀▀ █ █ ▀ ▀▀▀▀▀▀▀
▀ ▀█▀▀▀ ▄▀ █▄▄█▀▀██ ▄
█▀▀█▀▄▄▀█▄█▄█▀ ██▀
▀▀▀ ▀▀█▀▀ █ █ ▄ ▀
█▀▀▀▀▀█ ▄▀▄▀ ▀ ▄█▄██
█ ███ █ █▄ █▄█▄▄▀▄ ▀
█ ▀▀▀ █ ▀█ ▄█▄█▀▄▄█
▀▀▀▀▀▀▀ ▀▀ ▀ ▀ ▀
Current MSRV is 1.48.0