#[non_exhaustive]pub struct ParseOptions {
pub resolve_relative_uris: bool,
pub sanitize_html: bool,
pub limits: ParserLimits,
}Expand description
Parser configuration options
Controls various aspects of feed parsing behavior including URL resolution,
HTML sanitization, and resource limits for DoS protection.
§Examples
use feedparser_rs::ParseOptions;
// Default options (recommended for most use cases)
let options = ParseOptions::default();
assert!(options.resolve_relative_uris);
assert!(options.sanitize_html);
// Custom options for restricted environment
let custom = ParseOptions::default()
.with_resolve_relative_uris(true)
.with_sanitize_html(false)
.with_limits(feedparser_rs::ParserLimits::strict());Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.resolve_relative_uris: boolWhether to resolve relative URLs to absolute URLs
When true, relative URLs in links, images, and other resources
are converted to absolute URLs using the feed’s base URL.
Default: true
§Examples
use feedparser_rs::ParseOptions;
let mut options = ParseOptions::default();
options.resolve_relative_uris = false; // Keep relative URLssanitize_html: boolWhether to sanitize HTML content in feed entries
When true, HTML content in titles, summaries, and content blocks
is sanitized to remove potentially dangerous elements and attributes
(scripts, iframes, etc.) while preserving safe formatting.
Default: true
§Security
Disabling HTML sanitization is not recommended unless you fully trust the feed source and have other security measures in place.
§Examples
use feedparser_rs::ParseOptions;
let mut options = ParseOptions::default();
options.sanitize_html = false; // Disable for trusted feedslimits: ParserLimitsParser limits for DoS protection
Controls maximum allowed sizes for collections, text fields, and overall feed size to prevent resource exhaustion attacks.
Default: ParserLimits::default()
§Examples
use feedparser_rs::{ParseOptions, ParserLimits};
let options = ParseOptions::default().with_limits(ParserLimits::strict());Implementations§
Source§impl ParseOptions
impl ParseOptions
Sourcepub const fn with_limits(self, limits: ParserLimits) -> Self
pub const fn with_limits(self, limits: ParserLimits) -> Self
Returns a copy with the parser limits replaced.
Sourcepub const fn with_sanitize_html(self, sanitize_html: bool) -> Self
pub const fn with_sanitize_html(self, sanitize_html: bool) -> Self
Returns a copy with HTML sanitization switched on or off.
Sourcepub const fn with_resolve_relative_uris(
self,
resolve_relative_uris: bool,
) -> Self
pub const fn with_resolve_relative_uris( self, resolve_relative_uris: bool, ) -> Self
Returns a copy with relative-URI resolution switched on or off.
Sourcepub const fn permissive() -> Self
pub const fn permissive() -> Self
Creates permissive parse options
Suitable for trusted feeds where you want maximum compatibility and performance:
resolve_relative_uris:truesanitize_html:falselimits:ParserLimits::permissive()
§Security Warning
Use only with trusted feed sources!
§Examples
use feedparser_rs::ParseOptions;
let options = ParseOptions::permissive();
assert!(!options.sanitize_html);Sourcepub const fn strict() -> Self
pub const fn strict() -> Self
Creates strict parse options
Suitable for untrusted feeds in resource-constrained environments:
resolve_relative_uris:false(preserve original URLs)sanitize_html:true(remove dangerous content)limits:ParserLimits::strict()(tight resource limits)
§Examples
use feedparser_rs::ParseOptions;
let options = ParseOptions::strict();
assert!(options.sanitize_html);
assert!(!options.resolve_relative_uris);