5个版本
0.1.4 | 2020年11月13日 |
---|---|
0.1.3 | 2020年11月13日 |
0.1.2 | 2020年11月11日 |
0.1.1 | 2020年11月10日 |
0.1.0 | 2020年7月1日 |
#2849 in 解析器实现
4MB
4K SLoC
Rust中的任天堂BYML(二进制YAML)库
这是一个简单的库,用于在Rust中读取、写入和转换任天堂二进制YAML(BYML)文件。支持BYML版本2-4,(v2用于《塞尔达传说:荒野之息》)。可以将BYML转换为可读、可编辑的YAML,并将其转换回BYML。
示例用法
// First grab the file bytes. Yaz0 compressed files are automatically decompressed.
let bytes: Vec<u8> = std::fs::read("ActorInfo.product.byml").unwrap();
// Parse the data as a Byml document
let actor_info: Byml = Byml::from_binary(&bytes).unwrap();
// Index BYML hashes and arrays naturally
let actor_list: &Vec<Byml> = actor_info["Actors"].as_array().unwrap();
// 7934 actors, egads!
assert_eq!(actor_list.len(), 7934);
// Hmm, we'll iterate the actors listed in this file:
for actor in actor_list.iter() {
// Print each actor's name
println!("{}", actor["name"].as_string().unwrap());
}
// Dump to YAML
std::fs::write("ActorInfo.product.yml", actor_info.to_text().unwrap()).unwrap();
许可声明
此软件包含大量修改后的来自yaml-rust
的代码,主要是为了简化BYML文本表示的解析和生成。原始的MIT/Apache许可证和代码可在GitHub仓库上找到。
依赖项
~5MB
~96K SLoC