rss_gen::error

Enum RssError

Source
#[non_exhaustive]
pub enum RssError {
Show 15 variants XmlWriteError(Error), XmlParseError(Error), Utf8Error(FromUtf8Error), MissingField(String), DateParseError(String), IoError(Error), InvalidInput(String), InvalidUrl(String), UnknownElement(String), ValidationErrors(Vec<String>), DateSortError(Vec<DateSortError>), ItemValidationError(String), UnknownField(String), Custom(String), InvalidRssVersion(String),
}
Expand description

Errors that can occur when generating or parsing RSS feeds.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

XmlWriteError(Error)

Error occurred while writing XML.

§

XmlParseError(Error)

Error occurred during XML parsing.

§

Utf8Error(FromUtf8Error)

Error occurred during UTF-8 conversion.

§

MissingField(String)

Error indicating a required field is missing.

§

DateParseError(String)

Error indicating a date parsing failure.

§

IoError(Error)

General I/O error.

§

InvalidInput(String)

Error for invalid input data.

§

InvalidUrl(String)

Error for invalid URL provided.

§

UnknownElement(String)

Error for unknown XML elements encountered during parsing.

§

ValidationErrors(Vec<String>)

Error for validation errors.

§

DateSortError(Vec<DateSortError>)

Error for date sort errors.

§

ItemValidationError(String)

Error for item validation errors.

§

UnknownField(String)

Error for unknown field encountered during parsing.

§

Custom(String)

Custom error for unforeseen scenarios.

§

InvalidRssVersion(String)

Error for invalid RSS version.

Implementations§

Source§

impl RssError

Source

pub fn missing_field<S: Into<String>>(field_name: S) -> Self

Creates a new RssError::MissingField error.

§Arguments
  • field_name - The name of the missing field.
§Returns

Returns a new RssError::MissingField instance.

Source

pub fn date_sort_error<S: Into<String>>( index: usize, message: S, ) -> DateSortError

Creates a new DateSortError.

§Arguments
  • index - The index of the item with the date sort error.
  • message - The error message.
§Returns

Returns a new DateSortError instance.

Source

pub fn invalid_input<S: Into<String>>(message: S) -> Self

Creates a new RssError::InvalidInput error.

§Arguments
  • message - A description of why the input is invalid.
§Returns

Returns a new RssError::InvalidInput instance.

Source

pub fn custom<S: Into<String>>(message: S) -> Self

Creates a new RssError::Custom error.

§Arguments
  • message - A custom error message.
§Returns

Returns a new RssError::Custom instance.

Source

pub fn log(&self)

Logs the error using the log crate.

This method logs the error at the error level. It uses the log crate, so the application using this library should configure a logger.

Source

pub fn to_http_status(&self) -> u16

Converts the RssError into an appropriate HTTP status code.

This method is useful when the library is used in web services.

§Returns

Returns a u16 representing an HTTP status code.

Trait Implementations§

Source§

impl Debug for RssError

Source§

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

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

impl Display for RssError

Source§

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

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

impl Error for RssError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for RssError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for RssError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<FromUtf8Error> for RssError

Source§

fn from(source: FromUtf8Error) -> Self

Converts to this type from the input type.

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> 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> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.
§

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

§

impl<T> MaybeSendSync for T