Struct xml::reader::ParserConfig2
source · #[non_exhaustive]pub struct ParserConfig2 {
pub override_encoding: Option<Encoding>,
pub ignore_invalid_encoding_declarations: bool,
pub allow_multiple_root_elements: bool,
/* private fields */
}
Expand description
Backwards-compatible extension of ParserConfig
, which will eventually be merged into the original ParserConfig
struct
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.override_encoding: Option<Encoding>
Use this encoding as the default. Necessary for UTF-16 files without BOM.
ignore_invalid_encoding_declarations: bool
Allow <?xml encoding="…">
to contain unsupported encoding names,
and interpret them as Latin1 instead. This will mangle non-ASCII characters, but usually it won’t fail parsing.
allow_multiple_root_elements: bool
Documents with multiple root elements are ill-formed
Implementations§
source§impl ParserConfig2
impl ParserConfig2
pub fn new() -> Self
sourcepub fn content_type(self, mime_type: &str) -> Self
pub fn content_type(self, mime_type: &str) -> Self
Read character encoding from Content-Type
header.
Set this when parsing XML documents fetched over HTTP.
text/*
MIME types do not imply latin1. UTF-8 is always the default fallback.
sourcepub fn create_reader<R: Read>(self, source: R) -> EventReader<R>
pub fn create_reader<R: Read>(self, source: R) -> EventReader<R>
Creates an XML reader with this configuration.
This is a convenience method for configuring and creating a reader at the same time:
use xml::reader::ParserConfig;
let mut source: &[u8] = b"...";
let reader = ParserConfig::new()
.trim_whitespace(true)
.ignore_comments(true)
.coalesce_characters(false)
.create_reader(&mut source);
This method is exactly equivalent to calling EventReader::new_with_config()
with
this configuration object.
source§impl ParserConfig2
impl ParserConfig2
sourcepub fn override_encoding(self, value: Option<Encoding>) -> ParserConfig2
pub fn override_encoding(self, value: Option<Encoding>) -> ParserConfig2
See ParserConfig
fields docs for details
source§impl ParserConfig2
impl ParserConfig2
sourcepub fn allow_multiple_root_elements(self, value: bool) -> ParserConfig2
pub fn allow_multiple_root_elements(self, value: bool) -> ParserConfig2
See ParserConfig
fields docs for details
source§impl ParserConfig2
impl ParserConfig2
sourcepub fn ignore_invalid_encoding_declarations(self, value: bool) -> ParserConfig2
pub fn ignore_invalid_encoding_declarations(self, value: bool) -> ParserConfig2
See ParserConfig
fields docs for details
source§impl ParserConfig2
impl ParserConfig2
sourcepub fn trim_whitespace(self, value: bool) -> ParserConfig2
pub fn trim_whitespace(self, value: bool) -> ParserConfig2
See ParserConfig
fields docs for details
source§impl ParserConfig2
impl ParserConfig2
sourcepub fn whitespace_to_characters(self, value: bool) -> ParserConfig2
pub fn whitespace_to_characters(self, value: bool) -> ParserConfig2
See ParserConfig
fields docs for details
source§impl ParserConfig2
impl ParserConfig2
sourcepub fn cdata_to_characters(self, value: bool) -> ParserConfig2
pub fn cdata_to_characters(self, value: bool) -> ParserConfig2
See ParserConfig
fields docs for details
source§impl ParserConfig2
impl ParserConfig2
sourcepub fn ignore_comments(self, value: bool) -> ParserConfig2
pub fn ignore_comments(self, value: bool) -> ParserConfig2
See ParserConfig
fields docs for details
source§impl ParserConfig2
impl ParserConfig2
sourcepub fn coalesce_characters(self, value: bool) -> ParserConfig2
pub fn coalesce_characters(self, value: bool) -> ParserConfig2
See ParserConfig
fields docs for details
source§impl ParserConfig2
impl ParserConfig2
sourcepub fn ignore_end_of_stream(self, value: bool) -> ParserConfig2
pub fn ignore_end_of_stream(self, value: bool) -> ParserConfig2
See ParserConfig
fields docs for details
source§impl ParserConfig2
impl ParserConfig2
sourcepub fn replace_unknown_entity_references(self, value: bool) -> ParserConfig2
pub fn replace_unknown_entity_references(self, value: bool) -> ParserConfig2
See ParserConfig
fields docs for details
source§impl ParserConfig2
impl ParserConfig2
sourcepub fn ignore_root_level_whitespace(self, value: bool) -> ParserConfig2
pub fn ignore_root_level_whitespace(self, value: bool) -> ParserConfig2
See ParserConfig
fields docs for details
Trait Implementations§
source§impl Clone for ParserConfig2
impl Clone for ParserConfig2
source§fn clone(&self) -> ParserConfig2
fn clone(&self) -> ParserConfig2
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ParserConfig2
impl Debug for ParserConfig2
source§impl Default for ParserConfig2
impl Default for ParserConfig2
source§impl From<ParserConfig> for ParserConfig2
impl From<ParserConfig> for ParserConfig2
source§fn from(c: ParserConfig) -> Self
fn from(c: ParserConfig) -> Self
source§impl PartialEq<ParserConfig2> for ParserConfig2
impl PartialEq<ParserConfig2> for ParserConfig2
source§fn eq(&self, other: &ParserConfig2) -> bool
fn eq(&self, other: &ParserConfig2) -> bool
self
and other
values to be equal, and is used
by ==
.