pub struct Item {Show 14 fields
pub title: Option<String>,
pub link: Option<String>,
pub description: Option<String>,
pub author: Option<String>,
pub categories: Vec<Category>,
pub comments: Option<String>,
pub enclosure: Option<Enclosure>,
pub guid: Option<Guid>,
pub pub_date: Option<String>,
pub source: Option<Source>,
pub content: Option<String>,
pub extensions: ExtensionMap,
pub itunes_ext: Option<ITunesItemExtension>,
pub dublin_core_ext: Option<DublinCoreExtension>,
}
Expand description
Represents an item in an RSS feed.
Fields
title: Option<String>
The title of the item.
link: Option<String>
The URL of the item.
description: Option<String>
The item synopsis.
The email address of author of the item.
categories: Vec<Category>
The categories the item belongs to.
comments: Option<String>
The URL for the comments page of the item.
enclosure: Option<Enclosure>
The description of a media object that is attached to the item.
guid: Option<Guid>
A unique identifier for the item.
pub_date: Option<String>
The date the item was published as an RFC 2822 timestamp.
source: Option<Source>
The RSS channel the item came from.
content: Option<String>
The HTML contents of the item.
extensions: ExtensionMap
The extensions for the item.
itunes_ext: Option<ITunesItemExtension>
The iTunes extension for the item.
dublin_core_ext: Option<DublinCoreExtension>
The Dublin Core extension for the item.
Implementations
sourceimpl Item
impl Item
sourcepub fn title(&self) -> Option<&str>
pub fn title(&self) -> Option<&str>
Return the title of this item.
Examples
use rss::Item;
let mut item = Item::default();
item.set_title("Item Title".to_string());
assert_eq!(item.title(), Some("Item Title"));
sourcepub fn set_title<V>(&mut self, title: V) where
V: Into<Option<String>>,
pub fn set_title<V>(&mut self, title: V) where
V: Into<Option<String>>,
Set the title of this item.
Examples
use rss::Item;
let mut item = Item::default();
item.set_title("Item Title".to_string());
sourcepub fn link(&self) -> Option<&str>
pub fn link(&self) -> Option<&str>
Return the URL of this item.
Examples
use rss::Item;
let mut item = Item::default();
item.set_link("http://example.com".to_string());
assert_eq!(item.link(), Some("http://example.com"));
sourcepub fn set_link<V>(&mut self, link: V) where
V: Into<Option<String>>,
pub fn set_link<V>(&mut self, link: V) where
V: Into<Option<String>>,
Set the URL of this item.
Examples
use rss::Item;
let mut item = Item::default();
item.set_link("http://example.com".to_string());
sourcepub fn description(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
Return the description of this item.
Examples
use rss::Item;
let mut item = Item::default();
item.set_description("Item description".to_string());
assert_eq!(item.description(), Some("Item description"));
sourcepub fn set_description<V>(&mut self, description: V) where
V: Into<Option<String>>,
pub fn set_description<V>(&mut self, description: V) where
V: Into<Option<String>>,
Return the description of this item.
Examples
use rss::Item;
let mut item = Item::default();
item.set_description("Item description".to_string());
Return the email address for the author of this item.
Examples
use rss::Item;
let mut item = Item::default();
item.set_author("John Doe".to_string());
assert_eq!(item.author(), Some("John Doe"));
Set the email address for the author of this item.
Examples
use rss::Item;
let mut item = Item::default();
item.set_author("John Doe".to_string());
sourcepub fn categories(&self) -> &[Category]
pub fn categories(&self) -> &[Category]
Return the categories that this item belongs to.
Examples
use rss::{Category, Item};
let mut item = Item::default();
item.set_categories(vec![Category::default()]);
assert_eq!(item.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 item belongs to.
sourcepub fn set_categories<V>(&mut self, categories: V) where
V: Into<Vec<Category>>,
pub fn set_categories<V>(&mut self, categories: V) where
V: Into<Vec<Category>>,
Set the categories that this item belongs to.
Examples
use rss::{Category, Item};
let mut item = Item::default();
item.set_categories(vec![Category::default()]);
sourcepub fn comments(&self) -> Option<&str>
pub fn comments(&self) -> Option<&str>
Return the URL for comments about this item.
Examples
use rss::Item;
let mut item = Item::default();
item.set_comments("http://example.com".to_string());
assert_eq!(item.comments(), Some("http://example.com"));
sourcepub fn set_comments<V>(&mut self, comments: V) where
V: Into<Option<String>>,
pub fn set_comments<V>(&mut self, comments: V) where
V: Into<Option<String>>,
Set the URL for comments about this item.
Examples
use rss::Item;
let mut item = Item::default();
item.set_comments("http://example.com".to_string());
sourcepub fn enclosure(&self) -> Option<&Enclosure>
pub fn enclosure(&self) -> Option<&Enclosure>
Return the enclosure information for this item.
Examples
use rss::{Enclosure, Item};
let mut item = Item::default();
item.set_enclosure(Enclosure::default());
assert!(item.enclosure().is_some());
sourcepub fn set_enclosure<V>(&mut self, enclosure: V) where
V: Into<Option<Enclosure>>,
pub fn set_enclosure<V>(&mut self, enclosure: V) where
V: Into<Option<Enclosure>>,
Set the enclosure information for this item.
Examples
use rss::{Enclosure, Item};
let mut item = Item::default();
item.set_enclosure(Enclosure::default());
sourcepub fn guid(&self) -> Option<&Guid>
pub fn guid(&self) -> Option<&Guid>
Return the GUID for this item.
Examples
use rss::{Guid, Item};
let mut item = Item::default();
item.set_guid(Guid::default());
assert!(item.guid().is_some())
sourcepub fn set_guid<V>(&mut self, guid: V) where
V: Into<Option<Guid>>,
pub fn set_guid<V>(&mut self, guid: V) where
V: Into<Option<Guid>>,
Set the GUID for this item.
Examples
use rss::{Guid, Item};
let mut item = Item::default();
item.set_guid(Guid::default());
sourcepub fn pub_date(&self) -> Option<&str>
pub fn pub_date(&self) -> Option<&str>
Return the publication date of this item as an RFC 2822 timestamp.
Examples
use rss::Item;
let mut item = Item::default();
item.set_pub_date("Sun, 01 Jan 2017 12:00:00 GMT".to_string());
assert_eq!(item.pub_date(), Some("Sun, 01 Jan 2017 12:00:00 GMT"));
sourcepub fn set_pub_date<V>(&mut self, pub_date: V) where
V: Into<Option<String>>,
pub fn set_pub_date<V>(&mut self, pub_date: V) where
V: Into<Option<String>>,
Set the publication date of this item as an RFC 2822 timestamp.
Examples
use rss::Item;
let mut item = Item::default();
item.set_pub_date("Sun, 01 Jan 2017 12:00:00 GMT".to_string());
assert_eq!(item.pub_date(), Some("Sun, 01 Jan 2017 12:00:00 GMT"));
Using chrono::DateTime
use rss::Item;
use chrono::{FixedOffset, TimeZone, Utc};
let mut item = Item::default();
item.set_pub_date(Utc.ymd(2017, 1, 1).and_hms(12, 0, 0).to_rfc2822());
assert_eq!(item.pub_date(), Some("Sun, 01 Jan 2017 12:00:00 +0000"));
item.set_pub_date(FixedOffset::east(2 * 3600).ymd(2017, 1, 1).and_hms(12, 0, 0).to_rfc2822());
assert_eq!(item.pub_date(), Some("Sun, 01 Jan 2017 12:00:00 +0200"));
sourcepub fn source(&self) -> Option<&Source>
pub fn source(&self) -> Option<&Source>
Return the source URL for this item.
Examples
use rss::{Item, Source};
let mut item = Item::default();
item.set_source(Source::default());
assert!(item.source().is_some());
sourcepub fn set_source<V>(&mut self, source: V) where
V: Into<Option<Source>>,
pub fn set_source<V>(&mut self, source: V) where
V: Into<Option<Source>>,
Set the source URL for this item.
Examples
use rss::{Item, Source};
let mut item = Item::default();
item.set_source(Source::default());
sourcepub fn content(&self) -> Option<&str>
pub fn content(&self) -> Option<&str>
Return the content of this item.
Examples
use rss::Item;
let mut item = Item::default();
item.set_content("Item content".to_string());
assert_eq!(item.content(), Some("Item content"));
sourcepub fn set_content<V>(&mut self, content: V) where
V: Into<Option<String>>,
pub fn set_content<V>(&mut self, content: V) where
V: Into<Option<String>>,
Set the content of this item.
Examples
use rss::Item;
let mut item = Item::default();
item.set_content("Item content".to_string());
sourcepub fn itunes_ext(&self) -> Option<&ITunesItemExtension>
pub fn itunes_ext(&self) -> Option<&ITunesItemExtension>
Return the iTunes extension for this item.
Examples
use rss::Item;
use rss::extension::itunes::ITunesItemExtension;
let mut item = Item::default();
item.set_itunes_ext(ITunesItemExtension::default());
assert!(item.itunes_ext().is_some());
sourcepub fn set_itunes_ext<V>(&mut self, itunes_ext: V) where
V: Into<Option<ITunesItemExtension>>,
pub fn set_itunes_ext<V>(&mut self, itunes_ext: V) where
V: Into<Option<ITunesItemExtension>>,
Set the iTunes extension for this item.
Examples
use rss::Item;
use rss::extension::itunes::ITunesItemExtension;
let mut item = Item::default();
item.set_itunes_ext(ITunesItemExtension::default());
sourcepub fn dublin_core_ext(&self) -> Option<&DublinCoreExtension>
pub fn dublin_core_ext(&self) -> Option<&DublinCoreExtension>
Return the Dublin Core extension for this item.
Examples
use rss::Item;
use rss::extension::dublincore::DublinCoreExtension;
let mut item = Item::default();
item.set_dublin_core_ext(DublinCoreExtension::default());
assert!(item.dublin_core_ext().is_some());
sourcepub fn set_dublin_core_ext<V>(&mut self, dublin_core_ext: V) where
V: Into<Option<DublinCoreExtension>>,
pub fn set_dublin_core_ext<V>(&mut self, dublin_core_ext: V) where
V: Into<Option<DublinCoreExtension>>,
Set the Dublin Core extension for this item.
Examples
use rss::Item;
use rss::extension::dublincore::DublinCoreExtension;
let mut item = Item::default();
item.set_dublin_core_ext(DublinCoreExtension::default());
sourcepub fn extensions(&self) -> &ExtensionMap
pub fn extensions(&self) -> &ExtensionMap
Return the extensions for this item.
Examples
use std::collections::BTreeMap;
use rss::Item;
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 item = Item::default();
item.set_extensions(extension_map);
assert_eq!(item.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 item.
Examples
use rss::Item;
use rss::extension::ExtensionMap;
let mut item = Item::default();
item.set_extensions(ExtensionMap::default());
Trait Implementations
impl StructuralPartialEq for Item
Auto Trait Implementations
impl RefUnwindSafe for Item
impl Send for Item
impl Sync for Item
impl Unpin for Item
impl UnwindSafe for Item
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more