RSS syndication format library (port of the Rust rss crate)
Dependencies
///|
test {
let channel = try! Channel::read_from(
"<?xml version=\"1.0\"?><rss version=\"2.0\"><channel><title>News</title><link>https://example.com/</link><description>An example feed.</description><item><title>Hello</title></item></channel></rss>",
)
inspect(channel.title, content="News")
inspect(channel.items[0].title.unwrap_or(""), content="Hello")
}///|
test {
let channel = try! Channel::read_from(
"<rss version=\"2.0\"><channel><title>T</title><link>https://e.com/</link><description>D</description></channel></rss>",
)
let xml = channel.to_xml()
// Writing then parsing reproduces the same model.
let again = try! Channel::read_from(xml)
assert_true(again == channel)
}///|
test {
let channel = try! Channel::read_from(
"<rss version=\"2.0\"><channel><title>T</title><link>notaurl</link><description>D</description></channel></rss>",
)
let verdict = try {
ignore(channel.validate())
"ok"
} catch {
_ => "failed"
}
inspect(verdict, content="failed")
}///|
test {
let channel = try! Channel::read_from(
"<rss version=\"2.0\"><channel><title>T</title><link>https://e.com/</link><description>D</description></channel></rss>",
)
let feed = channel.to_atom()
inspect(feed.title.value, content="T")
let back = try! Channel::from_atom(feed)
assert_true(back.title == channel.title)
}impl Show for ValidationErrorpub(all) struct Channel {
title : String
link : String
description : String
language : String?
copyright : String?
managing_editor : String?
webmaster : String?
pub_date : String?
last_build_date : String?
categories : Array[Category]
generator : String?
docs : String?
cloud : Cloud?
rating : String?
ttl : String?
image : Image?
text_input : TextInput?
skip_hours : Array[String]
skip_days : Array[String]
items : Array[Item]
extensions : Map[String, Map[String, Array[Extension]]]
atom_links : Array[Link]
itunes_ext : ITunesChannelExtension?
dublin_core_ext : DublinCoreExtension?
syndication_ext : SyndicationExtension?
namespaces : Map[String, String]
} derive(Eq, Debug)pub(all) struct DublinCoreExtension {
contributors : Array[String]
coverages : Array[String]
creators : Array[String]
dates : Array[String]
descriptions : Array[String]
formats : Array[String]
identifiers : Array[String]
languages : Array[String]
publishers : Array[String]
relations : Array[String]
rights : Array[String]
sources : Array[String]
subjects : Array[String]
titles : Array[String]
types : Array[String]
} derive(Eq, Debug)pub(all) struct ITunesChannelExtension {
author : String?
block : String?
categories : Array[ITunesCategory]
image : String?
explicit : String?
complete : String?
new_feed_url : String?
owner : ITunesOwner?
subtitle : String?
summary : String?
keywords : String?
itunes_type : String?
} derive(Eq, Debug)pub(all) struct ITunesItemExtension {
author : String?
block : String?
image : String?
duration : String?
explicit : String?
closed_captioned : String?
order : String?
subtitle : String?
summary : String?
keywords : String?
episode : String?
season : String?
episode_type : String?
} derive(Eq, Debug)pub(all) struct Item {
title : String?
link : String?
description : String?
author : String?
categories : Array[Category]
comments : String?
enclosure : Enclosure?
guid : Guid?
pub_date : String?
source : Source?
content : String?
extensions : Map[String, Map[String, Array[Extension]]]
atom_links : Array[Link]
itunes_ext : ITunesItemExtension?
dublin_core_ext : DublinCoreExtension?
} derive(Eq, Debug)pub(all) struct SyndicationExtension {
period : UpdatePeriod
frequency : Int
base : String
} derive(Eq, Debug)impl Show for UpdatePeriodfn parse_rfc2822(s : String) -> Boolfn str_lexicographic(a : String, b : String) -> IntRSS syndication format library (port of the Rust rss crate)
Dependencies