pub struct Feed { /* private fields */ }
Expand description

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

Instantiates with an empty JSON object.

Returns the inner Map as a reference.

Returns the inner Map as a mutable reference.

Converts the type into the inner Map.

The required URL formatted version identifier.

Identifies what version of the spec the feed is suppose to be compliant with.

Sets the version identifier.

Removes the version identifier.

The optional name of the feed.

Sets the name of the feed.

Removes the name of the feed.

The optional URL which the feed is suppose to represent.

Sets the home page URL.

Removes the home page URL.

The optional URL which this feed can be retrieived from.

Sets the feed URL.

Removes the feed URL.

An optional description of the feed.

Sets the description of the feed.

Removes the description of the feed.

An optional meta description about the feed only intended to be viewed in the raw JSON form.

Sets the user comment.

Removes the user comment.

An optional pagination URL.

Sets the next URL.

Removes the next URL.

An optional URL to an icon for use in a list of items.

Sets the icon.

Removes the icon.

An optional URL to a favicon suitable for use in a list of feeds.

Sets the favicon URL.

Removes the favicon URL.

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.

The optional language which the feed data is written in.

Valid values are from RFC 5646.

Sets the language.

Removes the language.

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.

Sets the expired flag.

Removes the expired flag.

Optional subscription endpoints which can be used to received feed update notifications.

Subscription endpoints which can be used to received feed update notifications.

Sets the hubs.

Removes the hubs.

A required array of Items.

A required array of Items.

Sets the items.

Removes the items.

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

Trait Implementations

Converts this type into a mutable reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Deserialize this value from the given Serde deserializer. Read more

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.