14 个版本 (3 个稳定版)
2.0.0 | 2023 年 5 月 30 日 |
---|---|
1.1.0 | 2020 年 11 月 21 日 |
0.19.0 | 2020 年 10 月 22 日 |
156 在 图像 中
每月下载量 3,265
在 21 个 crate(直接使用 9 个) 中使用
310KB
7.5K SLoC
qr_code
QR 码编码器和解码器 [*] 在 Rust 中。 文档.
编码器
这个库基于 https://docs.rs/qrcode 进行了分支,主要是因为缺乏对结构化 QR 码(多个 QR 码)的支持,尽管已经推动了所需的最低限度的更改 https://github.com/kennytm/qrcode-rust/pull/44
此外,为了简化,已经删除了依赖项 image
、checked_int_cast
和模块 render
。
解码器 [*]
解码器部分基于 https://docs.rs/rqrr/0.3.0/rqrr/,不包括图像检测部分,且不打算从相机扫描 QR 码。
解码器仅用于测试目的,以便依赖库可以在测试期间运行往返。
示例
Bmp 图像生成
需要 bmp
功能
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();
生成此图像
看起来很小?
许多上下文支持针对像素化图像的缩放模式,例如在 html 中 image-rendering: pixelated;
作为替代方案,请参阅方法 Bmp::mul
和 Bmp::add_whitespace
Unicode 字符串生成
let qr_code = qr_code::QrCode::new(b"Hello").unwrap();
println!("{}", qr_code.to_string(false, 3));
生成此输出(在终端中看起来更好)
█▀▀▀▀▀█ ▀▀▀█ █▀▀▀▀▀█
█ ███ █ █ █ ▀ █ ███ █
█ ▀▀▀ █ ██ ▄▀ █ ▀▀▀ █
▀▀▀▀▀▀▀ █ █ ▀ ▀▀▀▀▀▀▀
▀ ▀█▀▀▀ ▄▀ █▄▄█▀▀██ ▄
█▀▀█▀▄▄▀█▄█▄█▀ ██▀
▀▀▀ ▀▀█▀▀ █ █ ▄ ▀
█▀▀▀▀▀█ ▄▀▄▀ ▀ ▄█▄██
█ ███ █ █▄ █▄█▄▄▀▄ ▀
█ ▀▀▀ █ ▀█ ▄█▄█▀▄▄█
▀▀▀▀▀▀▀ ▀▀ ▀ ▀ ▀
最低支持的 Rust 版本 (MSRV)
当前 MSRV 是 1.48.0
依赖关系
~0–260KB