[][src]Struct json_feed_model::Item

pub struct Item { /* fields omitted */ }

An item is a single object (blog post, story, etc.) in the feed list.

Valid Item

An Item must have an id property set and either a content_html or content_text property set.

Implementations

impl Item[src]

pub fn new() -> Self[src]

Instantiates with an empty JSON object.

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

Returns the inner Map as a reference.

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

Returns the inner Map as a mutable reference.

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

Converts the type into the inner Map.

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 set_id<T>(&mut self, value: T) -> Option<Value> where
    T: ToString
[src]

Sets the ID.

pub fn remove_id(&mut self) -> Option<Value>[src]

Removes the ID.

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

The optional URL which the item represents.

pub fn set_url<T>(&mut self, value: T) -> Option<Value> where
    T: ToString
[src]

Sets the URL.

pub fn remove_url(&mut self) -> Option<Value>[src]

Removes the URL.

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

An optional related external URL to the item.

pub fn set_external_url<T>(&mut self, value: T) -> Option<Value> where
    T: ToString
[src]

Sets the external URL.

pub fn remove_external_url(&mut self) -> Option<Value>[src]

Removes the external URL.

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

An optional title for the item.

pub fn set_title<T>(&mut self, value: T) -> Option<Value> where
    T: ToString
[src]

Sets the title.

pub fn remove_title(&mut self) -> Option<Value>[src]

Removes the title.

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

An optional HTML string representing the content.

pub fn set_content_html<T>(&mut self, value: T) -> Option<Value> where
    T: ToString
[src]

Sets the HTML content.

pub fn remove_content_html(&mut self) -> Option<Value>[src]

Removes the HTML content.

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

An optional plain text string representing the content.

pub fn set_content_text<T>(&mut self, value: T) -> Option<Value> where
    T: ToString
[src]

Sets the plain text content.

pub fn remove_content_text(&mut self) -> Option<Value>[src]

Removes the plain text content.

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

An optional summary of the item.

pub fn set_summary<T>(&mut self, value: T) -> Option<Value> where
    T: ToString
[src]

Sets the summary.

pub fn remove_summary(&mut self) -> Option<Value>[src]

Removes the summary.

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

An optional URL of an image representing the item.

pub fn set_image<T>(&mut self, value: T) -> Option<Value> where
    T: ToString
[src]

Sets the image.

pub fn remove_image(&mut self) -> Option<Value>[src]

Removes the image.

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

An optional URL of a banner image representing the item.

pub fn set_banner_image<T>(&mut self, value: T) -> Option<Value> where
    T: ToString
[src]

Sets the banner image.

pub fn remove_banner_image(&mut self) -> Option<Value>[src]

Removes the banner image.

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

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

pub fn set_date_published<T>(&mut self, value: T) -> Option<Value> where
    T: ToString
[src]

Sets the date published.

pub fn remove_date_published(&mut self) -> Option<Value>[src]

Removes the date published.

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

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

pub fn set_date_modified<T>(&mut self, value: T) -> Option<Value> where
    T: ToString
[src]

Sets the date modified.

pub fn remove_date_modified(&mut self) -> Option<Value>[src]

Removes the date modified.

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 author_mut(&mut self) -> Result<Option<AuthorMut<'_>>, 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 set_author(&mut self, value: Author) -> Option<Value>[src]

Sets the author.

pub fn remove_author(&mut self) -> Option<Value>[src]

Removes the author.

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

An optional array of authors.

pub fn authors_mut(&mut self) -> Result<Option<Vec<AuthorMut<'_>>>, Error>[src]

An optional array of authors.

pub fn set_authors<I>(&mut self, items: I) -> Option<Value> where
    I: IntoIterator<Item = Author>, 
[src]

Sets the authors.

pub fn remove_authors(&mut self) -> Option<Value>[src]

Removes the authors.

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

An optional array of plain text tags.

pub fn set_tags<I>(&mut self, values: I) -> Option<Value> where
    I: IntoIterator<Item = String>, 
[src]

Sets the tags.

pub fn remove_tags(&mut self) -> Option<Value>[src]

Removes the 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 set_language<T>(&mut self, value: T) -> Option<Value> where
    T: ToString
[src]

Sets the language.

pub fn remove_language(&mut self) -> Option<Value>[src]

Removes the language.

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

An optional array of relevant resources for the item.

pub fn attachments_mut(
    &mut self
) -> Result<Option<Vec<AttachmentMut<'_>>>, Error>
[src]

An optional array of relevant resources for the item.

pub fn set_attachments<I>(&mut self, items: I) -> Option<Value> where
    I: IntoIterator<Item = Attachment>, 
[src]

Sets the attachments.

pub fn remove_attachments(&mut self) -> Option<Value>[src]

Removes the attachments.

impl Item[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 AsMut<Map<String, Value>> for Item[src]

impl AsRef<Map<String, Value>> for Item[src]

impl Clone for Item[src]

impl Debug for Item[src]

impl Default for Item[src]

impl<'de> Deserialize<'de> for Item[src]

impl Eq for Item[src]

impl From<Map<String, Value>> for Item[src]

impl PartialEq<Item> for Item[src]

impl PartialEq<Map<String, Value>> for Item[src]

impl Serialize for Item[src]

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

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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[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.