Files
QRGen/examples/high_ecc.rs
T
Serendipity ce8063431e docs: 开源规范化 — doc comments + 社区文件 + 示例代码 + crates.io 就绪
- 为 core 公开 API 添加完整 doc comments(rustdoc 可用)
- 新增 .editorconfig / CONTRIBUTING / CODE_OF_CONDUCT / SECURITY
- 新增 Issue 模板(bug + feature)+ PR 模板
- 新增 3 个代码示例(examples/)
- 更新 Cargo.toml 元数据(description/repository/keywords/categories/MSRV)
- 更新 README + CHANGELOG
2026-06-19 18:56:28 +08:00

23 lines
673 B
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! QRGen 高纠错示例:生成可抵抗 30% 损坏的 QR 码
//!
//! 运行: `cargo run --example high_ecc`
use qr_core::qr::{QrCode, QrConfig, VersionMode};
use qr_core::version::EcLevel;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = QrConfig {
level: EcLevel::H, // 30% 纠错能力
version: VersionMode::Auto,
margin: 6, // 更大的静区
};
let qr = QrCode::encode("重要数据 - High ECC", config)?;
println!("版本: {}, 纠错: {:?}, 尺寸: {}×{}", qr.version.0, qr.level, qr.size(), qr.size());
let svg = qr.to_svg();
println!("SVG 生成成功: {} 字节", svg.len());
Ok(())
}