#[non_exhaustive]pub struct Config {
pub allow_dangling_amp: bool,
pub allow_unmatched_ends: bool,
pub check_comments: bool,
pub check_end_names: bool,
pub check_well_formedness: bool,
pub expand_empty_elements: bool,
pub trim_markup_names_in_closing_tags: bool,
pub trim_text_start: bool,
pub trim_text_end: bool,
pub max_element_depth: usize,
}Expand description
A parser configuration.
The current configuration can be retrieved with Reader::config() and
changed through Reader::config_mut().
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.allow_dangling_amp: boolWhether a lone ampersand (without a paired semicolon) is allowed in text
content. Unless enabled, a dangling ampersand yields
Error::IllFormed(UnclosedReference).
Default: false.
allow_unmatched_ends: boolWhether unmatched closing tag names are allowed. Unless enabled, a dangling
end tag yields Error::IllFormed(UnmatchedEndTag).
When set to true, it won’t check if a closing tag has a corresponding
opening tag at all. For example, <a></a></b> will be permitted.
Default: false.
check_comments: boolWhether comments are validated for the forbidden -- sequence. If enabled,
an invalid comment yields Error::IllFormed(DoubleHyphenInComment).
Default: false.
check_end_names: boolWhether mismatched closing tag names are detected. If enabled, a mismatch
yields Error::IllFormed(MismatchedEndTag).
When set to false, it won’t check if a closing tag matches the
corresponding opening tag. For example, <mytag></different_tag> will be
permitted.
Default: true.
check_well_formedness: boolWhether the full set of XML well-formedness constraints is enforced.
The default parsing path of this crate is deliberately as permissive as
quick-xml 0.41, which only detects a handful of problems. Setting this
flag turns the reader into a conforming non-validating XML processor:
the Char and Name productions, the document structure of section 2.1,
the grammar of the XML declaration and of the (internal) document type
declaration, and the entity-related constraints are all enforced, and
violations are reported as Error::NotWellFormed.
Validity constraints are never enforced — that would require reading the external DTD subset, which this crate does not do.
This check assumes that no white space is trimmed away, so it should not
be combined with trim_text_start.
Default: false.
expand_empty_elements: boolWhether empty elements are split into a Start and an End event.
When true, every Empty event from a self-closing tag like <tag/> is
expanded into a Start followed by an End.
Default: false.
Whether trailing white space after the markup name is trimmed in closing
tags (</a >).
Default: true.
trim_text_start: boolWhether white space before character data is removed. If, after trimming, a
Text event is empty it is not emitted.
Default: false.
trim_text_end: boolWhether white space after character data is removed. If, after trimming, a
Text event is empty it is not emitted.
Default: false.
max_element_depth: usizeMaximum number of open (unclosed) elements a
NsReader will accept while nesting namespace
scopes, before returning
Error::Namespace(NamespaceError::TooDeeplyNested)
instead of pushing another scope.
This guards NamespaceResolver’s
scope stack against unbounded growth from pathologically (or
maliciously) deep documents. Only NsReader
enforces it; the namespace-agnostic Reader does not track nesting
depth and is unaffected by this setting.
Default: DEFAULT_MAX_ELEMENT_DEPTH. Raise it if you need to read
documents nested deeper than that (there is no arithmetic-overflow
reason to keep it low — the underlying counter is a usize — only a
resource-usage one), or set it to usize::MAX to disable the check
entirely.
Implementations§
Source§impl Config
impl Config
Sourcepub fn trim_text(&mut self, trim: bool)
pub fn trim_text(&mut self, trim: bool)
Sets both trim_text_start and
trim_text_end to the same value.
Sourcepub fn enable_all_checks(&mut self, enable: bool)
pub fn enable_all_checks(&mut self, enable: bool)
Turns on or off all well-formedness checks, namely
check_comments,
check_end_names and
check_well_formedness.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
Available on crate feature serde-types only.
impl<'de> Deserialize<'de> for Config
serde-types only.