6 个版本 (重大更新)
使用旧的 Rust 2015
0.5.0 | 2019年10月26日 |
---|---|
0.4.0 | 2016年10月19日 |
0.3.0 | 2016年9月20日 |
0.2.0 | 2016年6月6日 |
0.1.0 | 2015年9月9日 |
#1399 在 网页编程
每月26次下载
用于 2 crates
11KB
91 行
rust-syndication
序列化 Atom 和 RSS 网页内容的库。基于 rust-atom 和 rust-rss。
用法
读取
let atom_str = r#"
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<id>urn:uuid:b3420f84-6bdf-4f46-a225-f1b9a14703b6</id>
<title>TechCrunch</title>
<updated>2019-04-01T07:30:00Z</updated>
<entry>
<id>urn:uuid:4ae8550b-2987-49fa-9f8c-54c180c418ac</id>
<title>Ford hires Elon Musk as CEO</title>
<updated>2019-04-01T07:30:00Z</updated>
</entry>
</feed>
"#;
match atom_str.parse::<Feed>().unwrap() {
Feed::Atom(atom_feed) => println!("Atom feed first entry: {:?}", atom_feed.entries[0].title),
_ => {}
};
let rss_str = r#"
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>TechCrunch</title>
<link>http://techcrunch.com</link>
<description>The latest technology news and information on startups</description>
<item>
<title>Ford hires Elon Musk as CEO</title>
<pubDate>01 Apr 2019 07:30:00 GMT</pubDate>
<description>In an unprecedented move, Ford hires Elon Musk.</description>
</item>
</channel>
</rss>
"#;
match rss_str.parse::<Feed>().unwrap() {
Feed::RSS(rss_feed) => println!("RSS feed first entry: {:?}",
rss_feed.items[0].title),
_ => {}
};
写入
目前不支持。
待办事项
- 将源解析为常用格式。
- 支持写入源。
许可协议
根据您的要求,许可协议为以下之一
- Apache 许可协议第 2.0 版,(LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT 许可协议 (LICENSE-MIT 或 http://opensource.org/licenses/MIT)
。
贡献
除非您明确说明,否则根据 Apache-2.0 许可证定义,您有意提交的任何贡献都应如上所述双许可,不附加任何额外条款或条件。
依赖关系
~7MB
~193K SLoC