Skip to main content

Config

Struct Config 

Source
#[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
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.
§allow_dangling_amp: bool

Whether 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: bool

Whether 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: bool

Whether comments are validated for the forbidden -- sequence. If enabled, an invalid comment yields Error::IllFormed(DoubleHyphenInComment).

Default: false.

§check_end_names: bool

Whether 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: bool

Whether 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: bool

Whether 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.

§trim_markup_names_in_closing_tags: bool

Whether trailing white space after the markup name is trimmed in closing tags (</a >).

Default: true.

§trim_text_start: bool

Whether white space before character data is removed. If, after trimming, a Text event is empty it is not emitted.

Default: false.

§trim_text_end: bool

Whether white space after character data is removed. If, after trimming, a Text event is empty it is not emitted.

Default: false.

§max_element_depth: usize

Maximum 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

Source

pub fn trim_text(&mut self, trim: bool)

Sets both trim_text_start and trim_text_end to the same value.

Source

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 Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

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

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

impl Default for Config

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Config

Available on crate feature serde-types only.
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 Eq for Config

Source§

impl PartialEq for Config

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for Config

Available on crate feature serde-types only.
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 StructuralPartialEq for Config

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, dest: *mut u8)

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

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

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.