2 个不稳定版本
0.4.0 | 2023年11月22日 |
---|---|
0.3.3 | 2023年11月15日 |
在 解析器实现 中排名第 2450
37KB
768 行(不包括注释)
xspf:纯 Rust 实现的 XML 可共享播放列表格式
目标
- 高性能
- 解析时宽松
- 序列化时严格
- 最小依赖
- 有用的文档
- 打印时分配最小
限制
- 不处理 URI。使用此库的用户应努力正确解析标签(如
<location>
)的相对 URI。 - 仅处理 UTF-8 文档。
概述
核心类型是 Playlist。
所有字段名称均来自 规范,但 camelCase 名称已更改为 snake_case。
示例
//! simple example: append a track to a playlist, giving proper credit.
use std::env::{args, var};
use xspf::{Playlist, Track};
fn main() {
let playlist_path = args().nth(1).unwrap();
let track_location = args().nth(2).unwrap();
let mut pl = Playlist::read_file(&playlist_path)
.expect("unable to read playlist from file");
// move the previous playlist identifier (and location) to the
// attribution section.
pl.accredit();
// add track
let mut track = Track::default();
track.location.push(track_location.to_string());
pl.track_list.push(track);
// set the creator field to the current user
pl.creator = Some(var("USER").expect("$USER is not set").to_string());
// modify the playlist file in-place
pl.write_file(&playlist_path)
.expect("unable to write playlist to file");
}
依赖项
~265KB