3 个版本 (稳定)
1.0.1 | 2024年3月1日 |
---|---|
0.1.0 | 2024年2月29日 |
在 解析器实现 中排名第 794
每月下载量 50 次
125KB
2.5K SLoC
Passes
一个用于生成 PassKit 通行证的 Rust 库,具有以下特点
- 读取和解析
.pkpass
文件 - 使用库 API 构建并通过库 API 生成通行证
- 使用证书签名通行证并将其压缩为
.pkpass
- 通过键名更改通行证字段值
- 支持通行证和字段的语义标签
- 在库中代表 Wallet Passes 标准的所有功能
文档
用法
将以下内容添加到您的 Cargo.toml
[dependencies]
passes = "0.1.0"
示例
构建简单通行证
// Creating pass
let pass = PassBuilder::new(PassConfig {
organization_name: "Test organization".into(),
description: "Super gentlememe pass".into(),
pass_type_identifier: "com.example.pass".into(),
team_identifier: "AA00AA0A0A".into(),
serial_number: "ABCDEFG1234567890".into(),
})
.grouping_identifier(String::from("com.example.pass.app"))
.logo_text("Test pass".into())
.build();
创建包并生成 .pkpass
文件
let mut package = Package::new(pass);
// Save package as .pkpass
let path = Path::new("test_pass.pkpass");
let file = match File::create(&path) {
Err(why) => panic!("couldn't create {}: {}", path.display(), why),
Ok(file) => file,
};
package.write(file).unwrap();
有关更多示例,请参阅 示例目录。
许可证
Passes 根据 MIT 许可证分发。请参阅 LICENSE。
依赖项
约 10-15MB
约 296K SLoC