Struct rss::Item

source ·
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.

§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§

source§

impl Item

source

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

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

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

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

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

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

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

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

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

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

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

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

source

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

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

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

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

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

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

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

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

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.with_ymd_and_hms(2017, 1, 1, 12, 0, 0).unwrap().to_rfc2822());
assert_eq!(item.pub_date(), Some("Sun, 1 Jan 2017 12:00:00 +0000"));

item.set_pub_date(FixedOffset::east_opt(2 * 3600).unwrap().with_ymd_and_hms(2017, 1, 1, 12, 0, 0).unwrap().to_rfc2822());
assert_eq!(item.pub_date(), Some("Sun, 1 Jan 2017 12:00:00 +0200"));
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());
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());
source

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

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

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

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

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

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

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

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

impl Item

source

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

Builds an Item from source XML

Trait Implementations§

source§

impl Clone for Item

source§

fn clone(&self) -> Item

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Item

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Item

source§

fn default() -> Item

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Item

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for Item

source§

fn eq(&self, other: &Item) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Item

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Validate for Item

source§

fn validate(&self) -> Result<(), ValidationError>

Validate the data against the RSS specification.
source§

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,