rss_gen::data

Struct RssItem

Source
#[non_exhaustive]
pub struct RssItem { pub guid: String, pub category: Option<String>, pub description: String, pub link: String, pub pub_date: String, pub title: String, pub author: String, pub comments: Option<String>, pub enclosure: Option<String>, pub source: Option<String>, pub creator: Option<String>, pub date: Option<String>, }
Expand description

Represents an item in the 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.
§guid: String

The GUID of the RSS item (unique identifier).

§category: Option<String>

The category of the RSS item.

§description: String

The description of the RSS item.

§link: String

The link to the RSS item.

§pub_date: String

The publication date of the RSS item.

§title: String

The title of the RSS item.

§author: String

The author of the RSS item.

§comments: Option<String>

The comments URL related to the RSS item (optional).

§enclosure: Option<String>

The enclosure (typically for media like podcasts) (optional).

§source: Option<String>

The source of the RSS item (optional).

§creator: Option<String>

The creator of the RSS item (optional).

§date: Option<String>

The date the RSS item was created (optional).

Implementations§

Source§

impl RssItem

Source

pub fn new() -> Self

Creates a new RssItem with default values.

Source

pub fn set<T: Into<String>>(self, field: RssItemField, value: T) -> Self

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

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

The updated RssItem instance.

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.
§Errors

This function returns an Err(RssError) in the following cases:

  • RssError::InvalidInput if any fields such as title, link, or description are missing or invalid.
  • RssError::ValidationErrors if there are multiple validation issues found (e.g., invalid link, missing title, etc.).
  • RssError::DateParseError if the pub_date cannot be parsed into a valid date.

Additionally, it can return an error if any of the custom validation rules are violated (e.g., maximum length for certain fields).

Source

pub fn pub_date_parsed(&self) -> Result<DateTime>

Parses the pub_date string into a DateTime object.

§Returns
  • Ok(DateTime) if the date is valid and successfully parsed.
  • Err(RssError) if the date is invalid or cannot be parsed.
§Errors

This function returns an Err(RssError) if the pub_date is invalid or cannot be parsed into a DateTime object.

Source

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

Sets the GUID.

Source

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

Sets the category.

Source

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

Sets the description.

Sets the link.

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 author<T: Into<String>>(self, value: T) -> Self

Sets the author.

Source

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

Sets the comments URL.

Source

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

Sets the enclosure.

Source

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

Sets the source.

Trait Implementations§

Source§

impl Clone for RssItem

Source§

fn clone(&self) -> RssItem

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RssItem

Source§

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

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

impl Default for RssItem

Source§

fn default() -> RssItem

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

impl<'de> Deserialize<'de> for RssItem

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 PartialEq for RssItem

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.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 RssItem

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 RssItem

Source§

impl StructuralPartialEq for RssItem

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 u8)

🔬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>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T