rss_gen::data

Struct RssData

source
#[non_exhaustive]
pub struct RssData {
Show 19 fields pub atom_link: String, pub author: String, pub category: String, pub copyright: String, pub description: String, pub docs: String, pub generator: String, pub guid: String, pub image: String, pub language: String, pub last_build_date: String, pub link: String, pub managing_editor: String, pub pub_date: String, pub title: String, pub ttl: String, pub webmaster: String, pub items: Vec<RssItem>, pub version: RssVersion,
}
Expand description

Represents the main structure for an RSS feed.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§atom_link: String

The Atom link of the RSS feed.

§author: String

The author of the RSS feed.

§category: String

The category of the RSS feed.

§copyright: String

The copyright notice for the content of the feed.

§description: String

The description of the RSS feed.

§docs: String

The docs link of the RSS feed.

§generator: String

The generator of the RSS feed.

§guid: String

The GUID of the RSS feed.

§image: String

The image URL of the RSS feed.

§language: String

The language of the RSS feed.

§last_build_date: String

The last build date of the RSS feed.

§link: String

The main link to the RSS feed.

§managing_editor: String

The managing editor of the RSS feed.

§pub_date: String

The publication date of the RSS feed.

§title: String

The title of the RSS feed.

§ttl: String

Time To Live (TTL), the number of minutes the feed should be cached before refreshing.

§webmaster: String

The webmaster of the RSS feed.

§items: Vec<RssItem>

A collection of additional items in the RSS feed.

§version: RssVersion

The version of the RSS feed.

Implementations§

source§

impl RssData

source

pub fn new(version: Option<RssVersion>) -> Self

Creates a new RssData instance with default values and a specified RSS version.

§Arguments
  • version - An optional RssVersion specifying the RSS version for the feed.
§Returns

A new RssData instance.

source

pub fn set<T: Into<String>>(self, key: &str, value: T) -> Self

Sets the value of a specified field and returns the RssData instance for method chaining.

§Arguments
  • key - The field to set.
  • value - The value to assign to the field.
§Returns

The updated RssData instance.

source

pub fn add_item(&mut self, item: RssItem)

Adds an item to the RSS feed.

This method appends the given RssItem to the items vector of the RssData struct.

§Arguments
  • item - The RssItem to be added to the feed.
source

pub fn remove_item(&mut self, guid: &str) -> bool

Removes an item from the RSS feed by its GUID.

§Arguments
  • guid - The GUID of the item to remove.
§Returns

true if an item was removed, false otherwise.

source

pub fn item_count(&self) -> usize

Returns the number of items in the RSS feed.

source

pub fn clear_items(&mut self)

Clears all items from the RSS feed.

source

pub fn validate(&self) -> Result<()>

Validates the RssData to ensure that all required fields are set and valid.

§Returns
  • Ok(()) if the RssData is valid.
  • Err(RssError) if any validation errors are found.
source

pub fn to_hash_map(&self) -> HashMap<String, String>

Converts the RssData into a HashMap<String, String> for easier manipulation.

§Returns

A HashMap<String, String> containing the RSS feed data.

source

pub fn version(self, version: RssVersion) -> Self

Sets the RSS version.

Sets the Atom link.

source

pub fn author<T: Into<String>>(self, value: T) -> Self

Sets the author.

source

pub fn category<T: Into<String>>(self, value: T) -> Self

Sets the category.

source

pub fn copyright<T: Into<String>>(self, value: T) -> Self

Sets the copyright.

source

pub fn description<T: Into<String>>(self, value: T) -> Self

Sets the description.

source

pub fn docs<T: Into<String>>(self, value: T) -> Self

Sets the docs link.

source

pub fn generator<T: Into<String>>(self, value: T) -> Self

Sets the generator.

source

pub fn guid<T: Into<String>>(self, value: T) -> Self

Sets the GUID.

source

pub fn image<T: Into<String>>(self, value: T) -> Self

Sets the image URL.

source

pub fn language<T: Into<String>>(self, value: T) -> Self

Sets the language.

source

pub fn last_build_date<T: Into<String>>(self, value: T) -> Self

Sets the last build date.

Sets the main link.

source

pub fn managing_editor<T: Into<String>>(self, value: T) -> Self

Sets the managing editor.

source

pub fn pub_date<T: Into<String>>(self, value: T) -> Self

Sets the publication date.

source

pub fn title<T: Into<String>>(self, value: T) -> Self

Sets the title.

source

pub fn ttl<T: Into<String>>(self, value: T) -> Self

Sets the TTL (Time To Live).

source

pub fn webmaster<T: Into<String>>(self, value: T) -> Self

Sets the webmaster.

Trait Implementations§

source§

impl Clone for RssData

source§

fn clone(&self) -> RssData

Returns a copy of the value. Read more
1.6.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for RssData

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for RssData

source§

fn default() -> RssData

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

impl<'de> Deserialize<'de> for RssData

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Hash for RssData

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.6.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for RssData

source§

fn eq(&self, other: &RssData) -> bool

Tests for self and other values to be equal, and is used by ==.
1.6.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for RssData

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for RssData

source§

impl StructuralPartialEq for RssData

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,