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
This commit is contained in:
2026-06-19 18:56:28 +08:00
parent cbcd4e5123
commit ce8063431e
17 changed files with 640 additions and 18 deletions
+22
View File
@@ -0,0 +1,22 @@
//! 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(())
}