[][src]Struct json_feed_model::ItemRef

pub struct ItemRef<'a> { /* fields omitted */ }

An Item implemented with a borrowed reference to a JSON object.

Implementations

impl<'a> ItemRef<'a>[src]

pub fn as_map(&self) -> &Map<String, Value>[src]

Returns the inner Map as a reference.

impl<'a> ItemRef<'a>[src]

pub fn to_item(&self) -> Item[src]

Clones the inner Map reference and returns an owned type.

pub fn id(&self) -> Result<Option<&str>, Error>[src]

A required unique identifier for an item.

Important

The ID should be unique across all items which have ever appeared in the feed. An item with the same exact ID as another item (even if it is no longer in the current JSON feed items array) are considered the same item.

Version 1.0 Incompatibility

While JSON Feed 1.0 permitted values which could be coerced into JSON strings (e.g. JSON numbers), this model supports only JSON strings. JSON Feed 1.1 strongly suggests to only use strings. In practice, the vast majority of feeds use strings.

If you wish to support non-String IDs, you can directly access the underlying Map with as_map_mut or an equivalent method and read the JSON value.

pub fn url(&self) -> Result<Option<&str>, Error>[src]

The optional URL which the item represents.

pub fn external_url(&self) -> Result<Option<&str>, Error>[src]

An optional related external URL to the item.

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

An optional title for the item.

pub fn content_html(&self) -> Result<Option<&str>, Error>[src]

An optional HTML string representing the content.

pub fn content_text(&self) -> Result<Option<&str>, Error>[src]

An optional plain text string representing the content.

pub fn summary(&self) -> Result<Option<&str>, Error>[src]

An optional summary of the item.

pub fn image(&self) -> Result<Option<&str>, Error>[src]

An optional URL of an image representing the item.

pub fn banner_image(&self) -> Result<Option<&str>, Error>[src]

An optional URL of a banner image representing the item.

pub fn date_published(&self) -> Result<Option<&str>, Error>[src]

The date which the item was published in RFC 3339 format.

pub fn date_modified(&self) -> Result<Option<&str>, Error>[src]

The date which the item was modified in RFC 3339 format.

pub fn author(&self) -> Result<Option<AuthorRef<'_>>, Error>[src]

An optional author.

Deprecation

The author field is deprecated in favor of the authors field as of JSON Feed 1.1.

pub fn authors(&self) -> Result<Option<Vec<AuthorRef<'_>>>, Error>[src]

An optional array of authors.

pub fn tags(&self) -> Result<Option<Vec<&str>>, Error>[src]

An optional array of plain text tags.

pub fn language(&self) -> Result<Option<&str>, Error>[src]

The optional language which the feed data is written in.

Valid values are from RFC 5646.

pub fn attachments(&self) -> Result<Option<Vec<AttachmentRef<'_>>>, Error>[src]

An optional array of relevant resources for the item.

impl<'a> ItemRef<'a>[src]

pub fn is_valid(&self, version: &Version<'_>) -> bool[src]

Verifies if the JSON data complies with a specific Version of the JSON Feed spec.

Trait Implementations

impl<'a> AsRef<Map<String, Value>> for ItemRef<'a>[src]

impl<'a> Debug for ItemRef<'a>[src]

impl<'a> Eq for ItemRef<'a>[src]

impl<'a> From<&'a Map<String, Value>> for ItemRef<'a>[src]

impl<'a> From<&'a mut Map<String, Value>> for ItemRef<'a>[src]

impl<'a> PartialEq<ItemRef<'a>> for ItemRef<'a>[src]

impl<'a> PartialEq<Map<String, Value>> for ItemRef<'a>[src]

impl<'a> Serialize for ItemRef<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for ItemRef<'a>

impl<'a> Send for ItemRef<'a>

impl<'a> Sync for ItemRef<'a>

impl<'a> Unpin for ItemRef<'a>

impl<'a> UnwindSafe for ItemRef<'a>

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, 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.