#[non_exhaustive]pub struct ParserConfig2 {
pub override_encoding: Option<Encoding>,
pub ignore_invalid_encoding_declarations: bool,
pub allow_multiple_root_elements: bool,
pub max_entity_expansion_length: usize,
pub max_entity_expansion_depth: u8,
pub max_name_length: usize,
pub max_attributes: usize,
pub max_attribute_length: usize,
pub max_data_length: usize,
/* 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
max_entity_expansion_length: usize
Abort if custom entities create a string longer than this
max_entity_expansion_depth: u8
Entities can expand into other entities this many times (be careful about exponential cost!)
max_name_length: usize
Maximum length of tag name or attribute name
max_attributes: usize
Max number of attributes per element
max_attribute_length: usize
Max number of bytes in each attribute
max_data_length: usize
Maximum length of strings reprsenting characters, comments, and processing instructions
Implementations§
Source§impl ParserConfig2
impl ParserConfig2
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 const fn override_encoding(self, value: Option<Encoding>) -> Self
pub const fn override_encoding(self, value: Option<Encoding>) -> Self
Set if you got one in the HTTP header
See ParserConfig
fields docs for details
Sourcepub const fn allow_multiple_root_elements(self, value: bool) -> Self
pub const fn allow_multiple_root_elements(self, value: bool) -> Self
Allows invalid documents. There should be only a single root element in XML.
See ParserConfig
fields docs for details
Sourcepub const fn max_entity_expansion_length(self, value: usize) -> Self
pub const fn max_entity_expansion_length(self, value: usize) -> Self
Abort if custom entities create a string longer than this
See ParserConfig
fields docs for details
Sourcepub const fn max_entity_expansion_depth(self, value: u8) -> Self
pub const fn max_entity_expansion_depth(self, value: u8) -> Self
Entities can expand into other entities this many times (be careful about exponential cost!)
See ParserConfig
fields docs for details
Sourcepub const fn max_attributes(self, value: usize) -> Self
pub const fn max_attributes(self, value: usize) -> Self
Max number of attributes per element
See ParserConfig
fields docs for details
Sourcepub const fn max_name_length(self, value: usize) -> Self
pub const fn max_name_length(self, value: usize) -> Self
Maximum length of tag name or attribute name
See ParserConfig
fields docs for details
Sourcepub const fn max_attribute_length(self, value: usize) -> Self
pub const fn max_attribute_length(self, value: usize) -> Self
Max number of bytes in each attribute
See ParserConfig
fields docs for details
Sourcepub const fn max_data_length(self, value: usize) -> Self
pub const fn max_data_length(self, value: usize) -> Self
Maximum length of strings reprsenting characters, comments, and processing instructions
See ParserConfig
fields docs for details
Sourcepub const fn ignore_invalid_encoding_declarations(self, value: bool) -> Self
pub const fn ignore_invalid_encoding_declarations(self, value: bool) -> Self
Allow <?xml encoding="bogus"?>
See ParserConfig
fields docs for details
Source§impl ParserConfig2
impl ParserConfig2
Sourcepub const fn trim_whitespace(self, value: bool) -> Self
pub const fn trim_whitespace(self, value: bool) -> Self
See ParserConfig
fields docs for details
Sourcepub const fn whitespace_to_characters(self, value: bool) -> Self
pub const fn whitespace_to_characters(self, value: bool) -> Self
See ParserConfig
fields docs for details
Sourcepub const fn cdata_to_characters(self, value: bool) -> Self
pub const fn cdata_to_characters(self, value: bool) -> Self
See ParserConfig
fields docs for details
Sourcepub const fn ignore_comments(self, value: bool) -> Self
pub const fn ignore_comments(self, value: bool) -> Self
See ParserConfig
fields docs for details
Sourcepub const fn coalesce_characters(self, value: bool) -> Self
pub const fn coalesce_characters(self, value: bool) -> Self
See ParserConfig
fields docs for details
Sourcepub const fn ignore_end_of_stream(self, value: bool) -> Self
pub const fn ignore_end_of_stream(self, value: bool) -> Self
See ParserConfig
fields docs for details
Sourcepub const fn replace_unknown_entity_references(self, value: bool) -> Self
pub const fn replace_unknown_entity_references(self, value: bool) -> Self
See ParserConfig
fields docs for details
Sourcepub const fn ignore_root_level_whitespace(self, value: bool) -> Self
pub const fn ignore_root_level_whitespace(self, value: bool) -> Self
Whether or not whitespace at the root level of the document is ignored. Default is true.
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 for ParserConfig2
impl PartialEq for ParserConfig2
impl Eq for ParserConfig2
impl StructuralPartialEq for ParserConfig2
Auto Trait Implementations§
impl Freeze for ParserConfig2
impl RefUnwindSafe for ParserConfig2
impl Send for ParserConfig2
impl Sync for ParserConfig2
impl Unpin for ParserConfig2
impl UnwindSafe for ParserConfig2
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
)