#[non_exhaustive]pub struct Config {
pub allow_unmatched_ends: bool,
pub check_comments: bool,
pub check_end_names: bool,
pub expand_empty_elements: bool,
pub trim_markup_names_in_closing_tags: bool,
pub trim_text_start: bool,
pub trim_text_end: bool,
}
Expand description
A struct that holds a parser configuration.
Current parser configuration can be retrieved by calling Reader::config()
and changed by changing properties of the object returned by a call to
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_unmatched_ends: bool
Whether unmatched closing tag names should be allowed. Unless enabled,
in case of a dangling end tag, the Error::IllFormed(UnmatchedEndTag)
is returned from read methods.
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.
Note that the emitted End
event will not be modified if this is enabled,
ie. it will contain the data of the unmatched end tag.
Note, that setting this to true
will lead to additional allocates that
needed to store tag name for an End
event.
Default: false
check_comments: bool
Whether comments should be validated. If enabled, in case of invalid comment
Error::IllFormed(DoubleHyphenInComment)
is returned from read methods.
When set to true
, every Comment
event will be checked for not
containing --
, which is not allowed in XML comments. Most of the time
we don’t want comments at all so we don’t really care about comment
correctness, thus the default value is false
to improve performance.
Default: false
check_end_names: bool
Whether mismatched closing tag names should be detected. If enabled, in
case of mismatch the Error::IllFormed(MismatchedEndTag)
is returned from
read methods.
Note, that start and end tags should match literally, they cannot have different prefixes even if both prefixes resolve to the same namespace. The XML
<outer xmlns="namespace" xmlns:p="namespace">
</p:outer>
is not valid, even though semantically the start tag is the same as the end tag. The reason is that namespaces are an extension of the original XML specification (without namespaces) and it should be backward-compatible.
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.
If the XML is known to be sane (already processed, etc.) this saves extra time.
Note that the emitted End
event will not be modified if this is disabled,
ie. it will contain the data of the mismatched end tag.
Note, that setting this to true
will lead to additional allocates that
needed to store tag name for an End
event. However if expand_empty_elements
is also set, only one additional allocation will be performed that support
both these options.
Default: true
expand_empty_elements: bool
Whether empty elements should be split into an Open
and a Close
event.
When set to true
, all Empty
events produced by a self-closing tag
like <tag/>
are expanded into a Start
event followed by an End
event. When set to false
(the default), those tags are represented by
an Empty
event instead.
Note, that setting this to true
will lead to additional allocates that
needed to store tag name for an End
event. However if check_end_names
is also set, only one additional allocation will be performed that support
both these options.
Default: false
Whether trailing whitespace after the markup name are trimmed in closing
tags </a >
.
If true
the emitted End
event is stripped of trailing whitespace
after the markup name.
Note that if set to false
and check_end_names
is true
the comparison
of markup names is going to fail erroneously if a closing tag contains
trailing whitespace.
Default: true
trim_text_start: bool
Whether whitespace before character data should be removed.
When set to true
, leading whitespace is trimmed in Text
events.
If after that the event is empty it will not be pushed.
Default: false
WARNING: With this option every text events will be trimmed which is
incorrect behavior when text events delimited by comments, processing
instructions or CDATA sections. To correctly trim data manually apply
BytesText::inplace_trim_start
and BytesText::inplace_trim_end
only to necessary events.
trim_text_end: bool
Whether whitespace after character data should be removed.
When set to true
, trailing whitespace is trimmed in Text
events.
If after that the event is empty it will not be pushed.
Default: false
WARNING: With this option every text events will be trimmed which is
incorrect behavior when text events delimited by comments, processing
instructions or CDATA sections. To correctly trim data manually apply
BytesText::inplace_trim_start
and BytesText::inplace_trim_end
only to necessary events.
Implementations§
source§impl Config
impl Config
sourcepub fn trim_text(&mut self, trim: bool)
pub fn trim_text(&mut self, trim: bool)
Set both trim_text_start
and trim_text_end
to the same value.
WARNING: With this option every text events will be trimmed which is
incorrect behavior when text events delimited by comments, processing
instructions or CDATA sections. To correctly trim data manually apply
BytesText::inplace_trim_start
and BytesText::inplace_trim_end
only to necessary events.
sourcepub fn enable_all_checks(&mut self, enable: bool)
pub fn enable_all_checks(&mut self, enable: bool)
Turn on or off all checks for well-formedness. Currently it is that settings:
Trait Implementations§
source§impl<'arbitrary> Arbitrary<'arbitrary> for Config
impl<'arbitrary> Arbitrary<'arbitrary> for Config
source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self
from the given unstructured data. Read moresource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Self
from the entirety of the given
unstructured data. Read moresource§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Config
impl StructuralPartialEq for Config
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)