pub struct Channel {Show 25 fields
pub title: String,
pub link: String,
pub description: String,
pub language: Option<String>,
pub copyright: Option<String>,
pub managing_editor: Option<String>,
pub webmaster: Option<String>,
pub pub_date: Option<String>,
pub last_build_date: Option<String>,
pub categories: Vec<Category>,
pub generator: Option<String>,
pub docs: Option<String>,
pub cloud: Option<Cloud>,
pub rating: Option<String>,
pub ttl: Option<String>,
pub image: Option<Image>,
pub text_input: Option<TextInput>,
pub skip_hours: Vec<String>,
pub skip_days: Vec<String>,
pub items: Vec<Item>,
pub extensions: ExtensionMap,
pub itunes_ext: Option<ITunesChannelExtension>,
pub dublin_core_ext: Option<DublinCoreExtension>,
pub syndication_ext: Option<SyndicationExtension>,
pub namespaces: BTreeMap<String, String>,
}
Expand description
Represents the channel of an RSS feed.
Fields§
§title: String
The name of the channel.
link: String
The URL for the website corresponding to the channel.
description: String
A description of the channel.
language: Option<String>
The language of the channel.
copyright: Option<String>
The copyright notice for the channel.
managing_editor: Option<String>
The email address for the managing editor.
webmaster: Option<String>
The email address for the webmaster.
pub_date: Option<String>
The publication date for the content of the channel as an RFC822 timestamp.
last_build_date: Option<String>
The date that the contents of the channel last changed as an RFC822 timestamp.
categories: Vec<Category>
The categories the channel belongs to.
generator: Option<String>
A string indicating the program used to generate the channel.
docs: Option<String>
A URL that points to the documentation for the RSS format.
cloud: Option<Cloud>
The cloud to register with to be notified of updates to the channel.
rating: Option<String>
The PICS rating for the channel.
ttl: Option<String>
The number of minutes the channel can be cached before refreshing.
image: Option<Image>
An image that can be displayed with the channel.
text_input: Option<TextInput>
A text input box that can be displayed with the channel.
skip_hours: Vec<String>
A hint to tell the aggregator which hours it can skip.
skip_days: Vec<String>
A hint to tell the aggregator which days it can skip.
items: Vec<Item>
The items in the channel.
extensions: ExtensionMap
The extensions for the channel.
itunes_ext: Option<ITunesChannelExtension>
The iTunes extension for the channel.
dublin_core_ext: Option<DublinCoreExtension>
The Dublin Core extension for the channel.
The Syndication extension for the channel.
namespaces: BTreeMap<String, String>
The namespaces present in the RSS tag.
Implementations§
Source§impl Channel
impl Channel
Sourcepub fn title(&self) -> &str
pub fn title(&self) -> &str
Return the title of this channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_title("Channel Title");
assert_eq!(channel.title(), "Channel Title");
Sourcepub fn set_title<V>(&mut self, title: V)
pub fn set_title<V>(&mut self, title: V)
Set the title of this channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_title("Channel Title");
Sourcepub fn link(&self) -> &str
pub fn link(&self) -> &str
Return the URL for the website corresponding to this channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_link("http://example.com");
assert_eq!(channel.link(), "http://example.com");
Sourcepub fn set_link<V>(&mut self, link: V)
pub fn set_link<V>(&mut self, link: V)
Set the URL for the website corresponding to this channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_link("http://example.com");
Sourcepub fn description(&self) -> &str
pub fn description(&self) -> &str
Return the description of this channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_description("Channel description");
assert_eq!(channel.description(), "Channel description");
Sourcepub fn set_description<V>(&mut self, description: V)
pub fn set_description<V>(&mut self, description: V)
Set the description of this channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_description("Channel description");
Sourcepub fn language(&self) -> Option<&str>
pub fn language(&self) -> Option<&str>
Return the language of this channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_language("en-US".to_string());
assert_eq!(channel.language(), Some("en-US"));
Sourcepub fn set_language<V>(&mut self, language: V)
pub fn set_language<V>(&mut self, language: V)
Set the language of this channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_language("en-US".to_string());
Sourcepub fn copyright(&self) -> Option<&str>
pub fn copyright(&self) -> Option<&str>
Return the copyright notice for this channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_copyright("© 2017 John Doe".to_string());
assert_eq!(channel.copyright(), Some("© 2017 John Doe"));
Sourcepub fn set_copyright<V>(&mut self, copyright: V)
pub fn set_copyright<V>(&mut self, copyright: V)
Set the copyright notice for this channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_copyright("© 2017 John Doe".to_string());
Sourcepub fn managing_editor(&self) -> Option<&str>
pub fn managing_editor(&self) -> Option<&str>
Return the email address for the managing editor of this channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_managing_editor("johndoe@example.com".to_string());
assert_eq!(channel.managing_editor(), Some("johndoe@example.com"));
Sourcepub fn set_managing_editor<V>(&mut self, managing_editor: V)
pub fn set_managing_editor<V>(&mut self, managing_editor: V)
Set the email address for the managing editor of this channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_managing_editor("johndoe@example.com".to_string());
assert_eq!(channel.managing_editor(), Some("johndoe@example.com"));
Sourcepub fn webmaster(&self) -> Option<&str>
pub fn webmaster(&self) -> Option<&str>
Return the email address for webmaster of this channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_webmaster("johndoe@example.com".to_string());
assert_eq!(channel.webmaster(), Some("johndoe@example.com"));
Sourcepub fn set_webmaster<V>(&mut self, webmaster: V)
pub fn set_webmaster<V>(&mut self, webmaster: V)
Set the email address for webmaster of this channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_webmaster("johndoe@example.com".to_string());
Sourcepub fn pub_date(&self) -> Option<&str>
pub fn pub_date(&self) -> Option<&str>
Return the publication date for the content of this channel as an RFC822 timestamp.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_pub_date("Sun, 1 Jan 2017 12:00:00 GMT".to_string());
assert_eq!(channel.pub_date(), Some("Sun, 1 Jan 2017 12:00:00 GMT"));
Sourcepub fn set_pub_date<V>(&mut self, pub_date: V)
pub fn set_pub_date<V>(&mut self, pub_date: V)
Set the publication date for the content of this channel as an RFC822 timestamp.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_pub_date("Sun, 1 Jan 2017 12:00:00 GMT".to_string());
assert_eq!(channel.pub_date(), Some("Sun, 1 Jan 2017 12:00:00 GMT"));
§Using chrono::DateTime
use rss::Channel;
use chrono::{TimeZone, Utc};
let mut channel = Channel::default();
channel.set_pub_date(Utc.with_ymd_and_hms(2017, 1, 1, 12, 0, 0).unwrap().to_rfc2822());
assert_eq!(channel.pub_date(), Some("Sun, 1 Jan 2017 12:00:00 +0000"));
Sourcepub fn last_build_date(&self) -> Option<&str>
pub fn last_build_date(&self) -> Option<&str>
Return the time that the content of this channel was last changed as an RFC822 timestamp.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_last_build_date("Sun, 1 Jan 2017 12:00:00 GMT".to_string());
assert_eq!(channel.last_build_date(), Some("Sun, 1 Jan 2017 12:00:00 GMT"));
Sourcepub fn set_last_build_date<V>(&mut self, last_build_date: V)
pub fn set_last_build_date<V>(&mut self, last_build_date: V)
Set the time that the content of this channel was last changed as an RFC822 timestamp.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_last_build_date("Sun, 1 Jan 2017 12:00:00 GMT".to_string());
assert_eq!(channel.last_build_date(), Some("Sun, 1 Jan 2017 12:00:00 GMT"));
§Using chrono::DateTime
use rss::Channel;
use chrono::{TimeZone, Utc};
let mut channel = Channel::default();
channel.set_last_build_date(Utc.with_ymd_and_hms(2017, 1, 1, 12, 0, 0).unwrap().to_rfc2822());
assert_eq!(channel.last_build_date(), Some("Sun, 1 Jan 2017 12:00:00 +0000"));
Sourcepub fn categories(&self) -> &[Category]
pub fn categories(&self) -> &[Category]
Return the categories that this channel belongs to.
§Examples
use rss::{Channel, Category};
let mut channel = Channel::default();
channel.set_categories(vec![Category::default()]);
assert_eq!(channel.categories().len(), 1);
Sourcepub fn categories_mut(&mut self) -> &mut [Category]
pub fn categories_mut(&mut self) -> &mut [Category]
Return a mutable slice of the categories that this channel belongs to.
Sourcepub fn set_categories<V>(&mut self, categories: V)
pub fn set_categories<V>(&mut self, categories: V)
Set the categories that this channel belongs to.
§Examples
use rss::{Channel, Category};
let mut channel = Channel::default();
channel.set_categories(vec![Category::default()]);
Sourcepub fn generator(&self) -> Option<&str>
pub fn generator(&self) -> Option<&str>
Return a string indicating the program used to generate the channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_generator("Program Name".to_string());
assert_eq!(channel.generator(), Some("Program Name"));
Sourcepub fn set_generator<V>(&mut self, generator: V)
pub fn set_generator<V>(&mut self, generator: V)
Set a string indicating the program used to generate the channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_generator("Program Name".to_string());
Sourcepub fn docs(&self) -> Option<&str>
pub fn docs(&self) -> Option<&str>
Return a URL that points to the documentation of the RSS format used in this channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_docs("https://cyber.harvard.edu/rss/rss.html".to_string());
assert_eq!(channel.docs(), Some("https://cyber.harvard.edu/rss/rss.html"));
Sourcepub fn set_docs<V>(&mut self, docs: V)
pub fn set_docs<V>(&mut self, docs: V)
Set a URL that points to the documentation of the RSS format used in this channel.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_docs("https://cyber.harvard.edu/rss/rss.html".to_string());
Sourcepub fn cloud(&self) -> Option<&Cloud>
pub fn cloud(&self) -> Option<&Cloud>
Return the information used to register with a cloud for notifications of updates to the channel.
§Examples
use rss::{Channel, Cloud};
let mut channel = Channel::default();
channel.set_cloud(Cloud::default());
assert!(channel.cloud().is_some());
Sourcepub fn set_cloud<V>(&mut self, cloud: V)
pub fn set_cloud<V>(&mut self, cloud: V)
Set the information used to register with a cloud for notifications of updates to the channel.
§Examples
use rss::{Channel, Cloud};
let mut channel = Channel::default();
channel.set_cloud(Cloud::default());
Sourcepub fn ttl(&self) -> Option<&str>
pub fn ttl(&self) -> Option<&str>
Return the time to live of this channel. This indicates the number of minutes the channel can be cached before needing to be refreshed.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_ttl("60".to_string());
assert_eq!(channel.ttl(), Some("60"));
Sourcepub fn set_ttl<V>(&mut self, ttl: V)
pub fn set_ttl<V>(&mut self, ttl: V)
Set the time to live of this channel. This indicates the number of minutes the channel can be cached before needing to be refreshed.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_ttl("60".to_string());
Sourcepub fn image(&self) -> Option<&Image>
pub fn image(&self) -> Option<&Image>
Return the image to be displayed with this channel.
§Examples
use rss::{Channel, Image};
let mut channel = Channel::default();
channel.set_image(Image::default());
assert!(channel.image().is_some());
Sourcepub fn set_image<V>(&mut self, image: V)
pub fn set_image<V>(&mut self, image: V)
Set the image to be displayed with this channel.
§Examples
use rss::{Channel, Image};
let mut channel = Channel::default();
channel.set_image(Image::default());
Sourcepub fn set_rating<V>(&mut self, rating: V)
pub fn set_rating<V>(&mut self, rating: V)
Set the PICS rating for this channel.
Sourcepub fn text_input(&self) -> Option<&TextInput>
pub fn text_input(&self) -> Option<&TextInput>
Return the information for a text box to be displayed with this channel.
§Examples
use rss::{Channel, TextInput};
let mut channel = Channel::default();
channel.set_text_input(TextInput::default());
assert!(channel.text_input().is_some());
Sourcepub fn set_text_input<V>(&mut self, text_input: V)
pub fn set_text_input<V>(&mut self, text_input: V)
Set the information for a text box to be displayed with this channel.
§Examples
use rss::{Channel, TextInput};
let mut channel = Channel::default();
channel.set_text_input(TextInput::default());
Sourcepub fn skip_hours(&self) -> &[String]
pub fn skip_hours(&self) -> &[String]
Return the hours that aggregators can skip for refreshing content.
§Examples
use rss::Channel;
let skip_hours = vec![6, 7, 8, 14, 22];
let mut channel = Channel::default();
channel.set_skip_hours(vec!["1".to_string()]);
assert_eq!(channel.skip_hours().len(), 1);
Sourcepub fn skip_hours_mut(&mut self) -> &mut [String]
pub fn skip_hours_mut(&mut self) -> &mut [String]
Return a mutable slice of the hours that aggregators can skip for refreshing content.
Sourcepub fn set_skip_hours<V>(&mut self, skip_hours: V)
pub fn set_skip_hours<V>(&mut self, skip_hours: V)
Set the hours that aggregators can skip for refreshing content.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_skip_hours(vec!["1".to_string()]);
Sourcepub fn skip_days(&self) -> &[String]
pub fn skip_days(&self) -> &[String]
Return the days that aggregators can skip for refreshing content.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_skip_days(vec!["Monday".to_string()]);
assert_eq!(channel.skip_days().len(), 1);
Sourcepub fn skip_days_mut(&mut self) -> &mut [String]
pub fn skip_days_mut(&mut self) -> &mut [String]
Return a mutable slice of the days that aggregators can skip for refreshing content.
Sourcepub fn set_skip_days<V>(&mut self, skip_days: V)
pub fn set_skip_days<V>(&mut self, skip_days: V)
Set the days that aggregators can skip for refreshing content.
§Examples
use rss::Channel;
let mut channel = Channel::default();
channel.set_skip_days(vec!["Monday".to_string()]);
Sourcepub fn items(&self) -> &[Item]
pub fn items(&self) -> &[Item]
Return the items in this channel.
§Examples
use rss::{Channel, Item};
let mut channel = Channel::default();
channel.set_items(vec![Item::default()]);
assert_eq!(channel.items().len(), 1);
Sourcepub fn items_mut(&mut self) -> &mut [Item]
pub fn items_mut(&mut self) -> &mut [Item]
Return a mutable slice of the items in this channel.
Sourcepub fn into_items(self) -> Vec<Item>
pub fn into_items(self) -> Vec<Item>
Consume the Channel
and return a vector of Item
s.
§Examples
use rss::{Channel, Item};
let mut channel = Channel::default();
channel.set_items(vec![Item::default()]);
assert_eq!(channel.into_items().len(), 1);
Sourcepub fn set_items<V>(&mut self, items: V)
pub fn set_items<V>(&mut self, items: V)
Set the items in this channel.
§Examples
use rss::{Channel, Item};
let mut channel = Channel::default();
channel.set_items(vec![Item::default()]);
Sourcepub fn itunes_ext(&self) -> Option<&ITunesChannelExtension>
pub fn itunes_ext(&self) -> Option<&ITunesChannelExtension>
Return the iTunes extension for this channel.
§Examples
use rss::Channel;
use rss::extension::itunes::ITunesChannelExtension;
let mut channel = Channel::default();
channel.set_itunes_ext(ITunesChannelExtension::default());
assert!(channel.itunes_ext().is_some());
Sourcepub fn set_itunes_ext<V>(&mut self, itunes_ext: V)
pub fn set_itunes_ext<V>(&mut self, itunes_ext: V)
Set the iTunes extension for this channel.
§Examples
use rss::Channel;
use rss::extension::itunes::ITunesChannelExtension;
let mut channel = Channel::default();
channel.set_itunes_ext(ITunesChannelExtension::default());
Sourcepub fn dublin_core_ext(&self) -> Option<&DublinCoreExtension>
pub fn dublin_core_ext(&self) -> Option<&DublinCoreExtension>
Return the Dublin Core extension for this channel.
§Examples
use rss::Channel;
use rss::extension::dublincore::DublinCoreExtension;
let mut channel = Channel::default();
channel.set_dublin_core_ext(DublinCoreExtension::default());
assert!(channel.dublin_core_ext().is_some());
Sourcepub fn set_dublin_core_ext<V>(&mut self, dublin_core_ext: V)
pub fn set_dublin_core_ext<V>(&mut self, dublin_core_ext: V)
Set the Dublin Core extension for this channel.
§Examples
use rss::Channel;
use rss::extension::dublincore::DublinCoreExtension;
let mut channel = Channel::default();
channel.set_dublin_core_ext(DublinCoreExtension::default());
Return the Syndication extension for this channel.
§Examples
use rss::Channel;
use rss::extension::syndication::SyndicationExtension;
let mut channel = Channel::default();
channel.set_syndication_ext(SyndicationExtension::default());
assert!(channel.syndication_ext().is_some());
Set the Syndication extension for this channel.
§Examples
use rss::Channel;
use rss::extension::syndication::SyndicationExtension;
let mut channel = Channel::default();
channel.set_syndication_ext(SyndicationExtension::default());
Sourcepub fn extensions(&self) -> &ExtensionMap
pub fn extensions(&self) -> &ExtensionMap
Return the extensions for this channel.
§Examples
use std::collections::BTreeMap;
use rss::Channel;
use rss::extension::{ExtensionMap, Extension};
let extension = Extension::default();
let mut item_map = BTreeMap::<String, Vec<Extension>>::new();
item_map.insert("ext:name".to_string(), vec![extension]);
let mut extension_map = ExtensionMap::default();
extension_map.insert("ext".to_string(), item_map);
let mut channel = Channel::default();
channel.set_extensions(extension_map);
assert_eq!(channel.extensions()
.get("ext")
.and_then(|m| m.get("ext:name"))
.map(|v| v.len()),
Some(1));
Sourcepub fn set_extensions<V>(&mut self, extensions: V)where
V: Into<ExtensionMap>,
pub fn set_extensions<V>(&mut self, extensions: V)where
V: Into<ExtensionMap>,
Set the extensions for this channel.
§Examples
use rss::Channel;
use rss::extension::ExtensionMap;
let mut channel = Channel::default();
channel.set_extensions(ExtensionMap::default());
Sourcepub fn namespaces(&self) -> &BTreeMap<String, String>
pub fn namespaces(&self) -> &BTreeMap<String, String>
Return the namespaces for this channel.
§Examples
use std::collections::BTreeMap;
use rss::Channel;
let mut namespaces = BTreeMap::new();
namespaces.insert("ext".to_string(), "http://example.com".to_string());
let mut channel = Channel::default();
channel.set_namespaces(namespaces);
assert_eq!(channel.namespaces().get("ext").map(String::as_str), Some("http://example.com"));