[][src]Struct rss::Item

pub struct Item {
    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>,
}

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.

author: Option<String>

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

impl Item[src]

pub fn title(&self) -> Option<&str>[src]

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

pub fn set_title<V>(&mut self, title: V) where
    V: Into<Option<String>>, 
[src]

Set the title of this item.

Examples

use rss::Item;

let mut item = Item::default();
item.set_title("Item Title".to_string());

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

Set the URL of this item.

Examples

use rss::Item;

let mut item = Item::default();
item.set_link("http://example.com".to_string());

pub fn description(&self) -> Option<&str>[src]

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

pub fn set_description<V>(&mut self, description: V) where
    V: Into<Option<String>>, 
[src]

Return the description of this item.

Examples

use rss::Item;

let mut item = Item::default();
item.set_description("Item description".to_string());

pub fn author(&self) -> Option<&str>[src]

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

pub fn set_author<V>(&mut self, author: V) where
    V: Into<Option<String>>, 
[src]

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());

pub fn categories(&self) -> &[Category][src]

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);

pub fn categories_mut(&mut self) -> &mut [Category][src]

Return a mutable slice of the categories that this item belongs to.

pub fn set_categories<V>(&mut self, categories: V) where
    V: Into<Vec<Category>>, 
[src]

Set the categories that this item belongs to.

Examples

use rss::{Category, Item};

let mut item = Item::default();
item.set_categories(vec![Category::default()]);

pub fn comments(&self) -> Option<&str>[src]

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

pub fn set_comments<V>(&mut self, comments: V) where
    V: Into<Option<String>>, 
[src]

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());

pub fn enclosure(&self) -> Option<&Enclosure>[src]

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());

pub fn set_enclosure<V>(&mut self, enclosure: V) where
    V: Into<Option<Enclosure>>, 
[src]

Set the enclosure information for this item.

Examples

use rss::{Enclosure, Item};

let mut item = Item::default();
item.set_enclosure(Enclosure::default());

pub fn guid(&self) -> Option<&Guid>[src]

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())

pub fn set_guid<V>(&mut self, guid: V) where
    V: Into<Option<Guid>>, 
[src]

Set the GUID for this item.

Examples

use rss::{Guid, Item};

let mut item = Item::default();
item.set_guid(Guid::default());

pub fn pub_date(&self) -> Option<&str>[src]

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

pub fn set_pub_date<V>(&mut self, pub_date: V) where
    V: Into<Option<String>>, 
[src]

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

pub fn source(&self) -> Option<&Source>[src]

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());

pub fn set_source<V>(&mut self, source: V) where
    V: Into<Option<Source>>, 
[src]

Set the source URL for this item.

Examples

use rss::{Item, Source};

let mut item = Item::default();
item.set_source(Source::default());

pub fn content(&self) -> Option<&str>[src]

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

pub fn set_content<V>(&mut self, content: V) where
    V: Into<Option<String>>, 
[src]

Set the content of this item.

Examples

use rss::Item;

let mut item = Item::default();
item.set_content("Item content".to_string());

pub fn itunes_ext(&self) -> Option<&ITunesItemExtension>[src]

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());

pub fn set_itunes_ext<V>(&mut self, itunes_ext: V) where
    V: Into<Option<ITunesItemExtension>>, 
[src]

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());

pub fn dublin_core_ext(&self) -> Option<&DublinCoreExtension>[src]

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());

pub fn set_dublin_core_ext<V>(&mut self, dublin_core_ext: V) where
    V: Into<Option<DublinCoreExtension>>, 
[src]

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());

pub fn extensions(&self) -> &ExtensionMap[src]

Return the extensions for this item.

Examples

use std::collections::HashMap;
use rss::Item;
use rss::extension::{ExtensionMap, Extension};

let extension = Extension::default();

let mut item_map = HashMap::<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));

pub fn set_extensions<V>(&mut self, extensions: V) where
    V: Into<ExtensionMap>, 
[src]

Set the extensions for this item.

Examples

use rss::Item;
use rss::extension::ExtensionMap;

let mut item = Item::default();
item.set_extensions(ExtensionMap::default());

impl Item[src]

pub fn from_xml<R: BufRead>(
    namespaces: &HashMap<String, String>,
    reader: &mut Reader<R>,
    _: Attributes<'_>
) -> Result<Self, Error>
[src]

Builds an Item from source XML

Trait Implementations

impl Clone for Item[src]

impl Debug for Item[src]

impl Default for Item[src]

impl PartialEq<Item> for Item[src]

impl StructuralPartialEq for Item[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.