[−][src]Struct json_feed_model::Feed
A list of items with associated metadata.
The type provides a view into a JSON object value with accessor methods for the standard properties.
Feed
owns the underlying JSON object data and provides methods to access the backing object itself
with as_map
, as_map_mut
, and into_inner
.
The underlying data is not guaranteed to be a valid JSON Feed.
Valid Feed
A Feed
must have the version
set to a valid JSON Feed version value, the title
property set, and the items
property set.
Example
use json_feed_model::{Feed}; let json = serde_json::json!({ "version": "https://jsonfeed.org/version/1.1", "title": "Lorem ipsum dolor sit amet.", "home_page_url": "https://example.org/", "feed_url": "https://example.org/feed.json", "items": [ { "id": "cd7f0673-8e81-4e13-b273-4bd1b83967d0", "content_text": "Aenean tristique dictum mauris, et.", "url": "https://example.org/aenean-tristique" }, { "id": "2bcb497d-c40b-4493-b5ae-bc63c74b48fa", "content_html": "Vestibulum non magna vitae tortor.", "url": "https://example.org/vestibulum-non" } ] }); let feed = json_feed_model::from_value(json).unwrap(); assert_eq!(feed.version()?, Some(json_feed_model::VERSION_1_1)); assert_eq!(feed.title()?, Some("Lorem ipsum dolor sit amet.")); assert_eq!(feed.home_page_url()?, Some("https://example.org/")); assert_eq!(feed.feed_url()?, Some("https://example.org/feed.json")); let items = feed.items()?; let items = items.unwrap(); assert_eq!(items.len(), 2); assert_eq!(items[0].id()?, Some("cd7f0673-8e81-4e13-b273-4bd1b83967d0")); assert_eq!( items[0].content_text()?, Some("Aenean tristique dictum mauris, et.") ); assert_eq!( items[0].url()?, Some("https://example.org/aenean-tristique") ); assert_eq!(items[1].id()?, Some("2bcb497d-c40b-4493-b5ae-bc63c74b48fa")); assert_eq!( items[1].content_html()?, Some("Vestibulum non magna vitae tortor.") ); assert_eq!(items[1].url()?, Some("https://example.org/vestibulum-non"));
Implementations
impl Feed
[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 version(&self) -> Result<Option<&str>, Error>
[src]
The required URL formatted version identifier.
Identifies what version of the spec the feed is suppose to be compliant with.
pub fn set_version<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
[src]
T: ToString,
Sets the version identifier.
pub fn remove_version(&mut self) -> Option<Value>
[src]
Removes the version identifier.
pub fn title(&self) -> Result<Option<&str>, Error>
[src]
The optional name of the feed.
pub fn set_title<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
[src]
T: ToString,
Sets the name of the feed.
pub fn remove_title(&mut self) -> Option<Value>
[src]
Removes the name of the feed.
pub fn home_page_url(&self) -> Result<Option<&str>, Error>
[src]
The optional URL which the feed is suppose to represent.
pub fn set_home_page_url<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
[src]
T: ToString,
Sets the home page URL.
pub fn remove_home_page_url(&mut self) -> Option<Value>
[src]
Removes the home page URL.
pub fn feed_url(&self) -> Result<Option<&str>, Error>
[src]
The optional URL which this feed can be retrieived from.
pub fn set_feed_url<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
[src]
T: ToString,
Sets the feed URL.
pub fn remove_feed_url(&mut self) -> Option<Value>
[src]
Removes the feed URL.
pub fn description(&self) -> Result<Option<&str>, Error>
[src]
An optional description of the feed.
pub fn set_description<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
[src]
T: ToString,
Sets the description of the feed.
pub fn remove_description(&mut self) -> Option<Value>
[src]
Removes the description of the feed.
pub fn user_comment(&self) -> Result<Option<&str>, Error>
[src]
An optional meta description about the feed only intended to be viewed in the raw JSON form.
pub fn set_user_comment<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
[src]
T: ToString,
Sets the user comment.
pub fn remove_user_comment(&mut self) -> Option<Value>
[src]
Removes the user comment.
pub fn next_url(&self) -> Result<Option<&str>, Error>
[src]
An optional pagination URL.
pub fn set_next_url<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
[src]
T: ToString,
Sets the next URL.
pub fn remove_next_url(&mut self) -> Option<Value>
[src]
Removes the next URL.
pub fn icon(&self) -> Result<Option<&str>, Error>
[src]
An optional URL to an icon for use in a list of items.
pub fn set_icon<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
[src]
T: ToString,
Sets the icon.
pub fn remove_icon(&mut self) -> Option<Value>
[src]
Removes the icon.
pub fn favicon(&self) -> Result<Option<&str>, Error>
[src]
An optional URL to a favicon suitable for use in a list of feeds.
pub fn set_favicon<T>(&mut self, value: T) -> Option<Value> where
T: ToString,
[src]
T: ToString,
Sets the favicon URL.
pub fn remove_favicon(&mut self) -> Option<Value>
[src]
Removes the favicon URL.
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]
I: IntoIterator<Item = Author>,
Sets the authors.
pub fn remove_authors(&mut self) -> Option<Value>
[src]
Removes the authors.
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]
T: ToString,
Sets the language.
pub fn remove_language(&mut self) -> Option<Value>
[src]
Removes the language.
pub fn expired(&self) -> Result<Option<bool>, Error>
[src]
Optionally determines if the feed will be updated in the future.
If true, the feed will not be updated in the future. If false or None
, then the feed may be updated in the future.
pub fn set_expired<T>(&mut self, value: bool) -> Option<Value>
[src]
Sets the expired flag.
pub fn remove_expired(&mut self) -> Option<Value>
[src]
Removes the expired flag.
pub fn hubs(&self) -> Result<Option<Vec<HubRef<'_>>>, Error>
[src]
Optional subscription endpoints which can be used to received feed update notifications.
pub fn hubs_mut(&mut self) -> Result<Option<Vec<HubMut<'_>>>, Error>
[src]
Subscription endpoints which can be used to received feed update notifications.
pub fn set_hubs<I>(&mut self, items: I) -> Option<Value> where
I: IntoIterator<Item = Hub>,
[src]
I: IntoIterator<Item = Hub>,
Sets the hubs.
pub fn remove_hubs(&mut self) -> Option<Value>
[src]
Removes the hubs.
pub fn items(&self) -> Result<Option<Vec<ItemRef<'_>>>, Error>
[src]
A required array of Items
.
pub fn items_mut(&mut self) -> Result<Option<Vec<ItemMut<'_>>>, Error>
[src]
A required array of Items
.
pub fn set_items<I>(&mut self, items: I) -> Option<Value> where
I: IntoIterator<Item = Item>,
[src]
I: IntoIterator<Item = Item>,
Sets the items.
pub fn remove_items(&mut self) -> Option<Value>
[src]
Removes the items.
impl Feed
[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 Feed
[src]
impl AsRef<Map<String, Value>> for Feed
[src]
impl Clone for Feed
[src]
impl Debug for Feed
[src]
impl Default for Feed
[src]
impl<'de> Deserialize<'de> for Feed
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Eq for Feed
[src]
impl From<Map<String, Value>> for Feed
[src]
impl PartialEq<Feed> for Feed
[src]
impl PartialEq<Map<String, Value>> for Feed
[src]
fn eq(&self, other: &Map<String, Value>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for Feed
[src]
Auto Trait Implementations
impl RefUnwindSafe for Feed
impl Send for Feed
impl Sync for Feed
impl Unpin for Feed
impl UnwindSafe for Feed
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,