Rust 的 RSS 开发包 rust-rss

码农软件 · 软件分类 · RSS/ATOM相关 · 2019-04-12 09:27:15

软件介绍

rust-rss 是 Rust 语言用来解析和生成 RSS 数据的开发包,示例代码:

生成:

use rss::{Channel, Item, Rss};

let item = Item {
    title: Some(String::from("Ford hires Elon Musk as CEO")),
    pub_date: Some(String::from("01 Apr 2019 07:30:00 GMT")),
    description: Some(String::from("In an unprecedented move, Ford hires Elon Musk.")),
    ..Default::default()
};

let channel = Channel {
    title: String::from("TechCrunch"),
    link: String::from("http://techcrunch.com"),
    description: String::from("The latest technology news and information on startups"),
    items: vec![item],
    ..Default::default()
};

let rss = Rss(channel);

let rss_string = rss.to_string();

解析:

use rss::Rss;

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>
"#;

let rss = rss_str.parse::<Rss>().unwrap();

本文地址:https://codercto.com/soft/d/3402.html

编程珠玑

编程珠玑

Jon Bentley / 黄倩、钱丽艳 / 人民邮电出版社 / 2008-10 / 39.00元

本书是计算机科学方面的经典名著。书的内容围绕程序设计人员面对的一系列实际问题展开。作者Jon Bentley 以其独有的洞察力和创造力,引导读者理解这些问题并学会解决方法,而这些正是程序员实际编程生涯中至关重要的。本书的特色是通过一些精心设计的有趣而又颇具指导意义的程序,对实用程序设计技巧及基本设计原则进行了透彻而睿智的描述,为复杂的编程问题提供了清晰而完备的解决思路。本书对各个层次的程序员都具有......一起来看看 《编程珠玑》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

SHA 加密
SHA 加密

SHA 加密工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具