Struct json_feed_model::Item
source · [−]pub struct Item { /* private fields */ }
Expand description
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
sourceimpl Item
impl Item
sourcepub fn as_map_mut(&mut self) -> &mut Map<String, Value>
pub fn as_map_mut(&mut self) -> &mut Map<String, Value>
Returns the inner Map
as a mutable reference.
sourcepub fn into_inner(self) -> Map<String, Value>
pub fn into_inner(self) -> Map<String, Value>
Converts the type into the inner Map
.
sourcepub fn id(&self) -> Result<Option<&str>, Error>
pub fn id(&self) -> Result<Option<&str>, Error>
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.
sourcepub fn remove_url(&mut self) -> Option<Value>
pub fn remove_url(&mut self) -> Option<Value>
Removes the URL.
sourcepub fn external_url(&self) -> Result<Option<&str>, Error>
pub fn external_url(&self) -> Result<Option<&str>, Error>
An optional related external URL to the item.
sourcepub fn set_external_url<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
pub fn set_external_url<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
Sets the external URL.
sourcepub fn remove_external_url(&mut self) -> Option<Value>
pub fn remove_external_url(&mut self) -> Option<Value>
Removes the external URL.
sourcepub fn remove_title(&mut self) -> Option<Value>
pub fn remove_title(&mut self) -> Option<Value>
Removes the title.
sourcepub fn content_html(&self) -> Result<Option<&str>, Error>
pub fn content_html(&self) -> Result<Option<&str>, Error>
An optional HTML string representing the content.
sourcepub fn set_content_html<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
pub fn set_content_html<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
Sets the HTML content.
sourcepub fn remove_content_html(&mut self) -> Option<Value>
pub fn remove_content_html(&mut self) -> Option<Value>
Removes the HTML content.
sourcepub fn content_text(&self) -> Result<Option<&str>, Error>
pub fn content_text(&self) -> Result<Option<&str>, Error>
An optional plain text string representing the content.
sourcepub fn set_content_text<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
pub fn set_content_text<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
Sets the plain text content.
sourcepub fn remove_content_text(&mut self) -> Option<Value>
pub fn remove_content_text(&mut self) -> Option<Value>
Removes the plain text content.
sourcepub fn set_summary<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
pub fn set_summary<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
Sets the summary.
sourcepub fn remove_summary(&mut self) -> Option<Value>
pub fn remove_summary(&mut self) -> Option<Value>
Removes the summary.
sourcepub fn image(&self) -> Result<Option<&str>, Error>
pub fn image(&self) -> Result<Option<&str>, Error>
An optional URL of an image representing the item.
sourcepub fn remove_image(&mut self) -> Option<Value>
pub fn remove_image(&mut self) -> Option<Value>
Removes the image.
An optional URL of a banner image representing the item.
Sets the banner image.
Removes the banner image.
sourcepub fn date_published(&self) -> Result<Option<&str>, Error>
pub fn date_published(&self) -> Result<Option<&str>, Error>
The date which the item was published in RFC 3339 format.
sourcepub fn set_date_published<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
pub fn set_date_published<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
Sets the date published.
sourcepub fn remove_date_published(&mut self) -> Option<Value>
pub fn remove_date_published(&mut self) -> Option<Value>
Removes the date published.
sourcepub fn date_modified(&self) -> Result<Option<&str>, Error>
pub fn date_modified(&self) -> Result<Option<&str>, Error>
The date which the item was modified in RFC 3339 format.
sourcepub fn set_date_modified<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
pub fn set_date_modified<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
Sets the date modified.
sourcepub fn remove_date_modified(&mut self) -> Option<Value>
pub fn remove_date_modified(&mut self) -> Option<Value>
Removes the date modified.
An optional author.
Deprecation
The author
field is deprecated in favor of the authors
field as of JSON Feed 1.1.
An optional author.
Deprecation
The author
field is deprecated in favor of the authors
field as of JSON Feed 1.1.
Sets the author.
Removes the author.
An optional array of authors.
An optional array of authors.
Sets the authors.
Removes the authors.
An optional array of plain text tags.
Sets the tags.
Removes the tags.
sourcepub fn language(&self) -> Result<Option<&str>, Error>
pub fn language(&self) -> Result<Option<&str>, Error>
The optional language which the feed data is written in.
Valid values are from RFC 5646.
sourcepub fn set_language<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
pub fn set_language<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
Sets the language.
sourcepub fn remove_language(&mut self) -> Option<Value>
pub fn remove_language(&mut self) -> Option<Value>
Removes the language.
sourcepub fn attachments(&self) -> Result<Option<Vec<AttachmentRef<'_>>>, Error>
pub fn attachments(&self) -> Result<Option<Vec<AttachmentRef<'_>>>, Error>
An optional array of relevant resources for the item.
sourcepub fn attachments_mut(
&mut self
) -> Result<Option<Vec<AttachmentMut<'_>>>, Error>
pub fn attachments_mut(
&mut self
) -> Result<Option<Vec<AttachmentMut<'_>>>, Error>
An optional array of relevant resources for the item.
sourcepub fn set_attachments<I>(&mut self, items: I) -> Option<Value> where
I: IntoIterator<Item = Attachment>,
pub fn set_attachments<I>(&mut self, items: I) -> Option<Value> where
I: IntoIterator<Item = Attachment>,
Sets the attachments.
sourcepub fn remove_attachments(&mut self) -> Option<Value>
pub fn remove_attachments(&mut self) -> Option<Value>
Removes the attachments.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Item
impl<'de> Deserialize<'de> for Item
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq 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