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

source

pub fn new() -> Self

source

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.

source

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

source

pub fn override_encoding(self, value: Option<Encoding>) -> ParserConfig2

See ParserConfig fields docs for details

source§

impl ParserConfig2

source

pub fn allow_multiple_root_elements(self, value: bool) -> ParserConfig2

See ParserConfig fields docs for details

source§

impl ParserConfig2

source

pub fn ignore_invalid_encoding_declarations(self, value: bool) -> ParserConfig2

See ParserConfig fields docs for details

source§

impl ParserConfig2

source

pub fn trim_whitespace(self, value: bool) -> ParserConfig2

See ParserConfig fields docs for details

source§

impl ParserConfig2

source

pub fn whitespace_to_characters(self, value: bool) -> ParserConfig2

See ParserConfig fields docs for details

source§

impl ParserConfig2

source

pub fn cdata_to_characters(self, value: bool) -> ParserConfig2

See ParserConfig fields docs for details

source§

impl ParserConfig2

source

pub fn ignore_comments(self, value: bool) -> ParserConfig2

See ParserConfig fields docs for details

source§

impl ParserConfig2

source

pub fn coalesce_characters(self, value: bool) -> ParserConfig2

See ParserConfig fields docs for details

source§

impl ParserConfig2

source

pub fn ignore_end_of_stream(self, value: bool) -> ParserConfig2

See ParserConfig fields docs for details

source§

impl ParserConfig2

source

pub fn replace_unknown_entity_references(self, value: bool) -> ParserConfig2

See ParserConfig fields docs for details

source§

impl ParserConfig2

source

pub fn ignore_root_level_whitespace(self, value: bool) -> ParserConfig2

See ParserConfig fields docs for details

Trait Implementations§

source§

impl Clone for ParserConfig2

source§

fn clone(&self) -> ParserConfig2

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for ParserConfig2

source§

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

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

impl Default for ParserConfig2

source§

fn default() -> Self

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

impl From<ParserConfig> for ParserConfig2

source§

fn from(c: ParserConfig) -> Self

Converts to this type from the input type.
source§

impl PartialEq<ParserConfig2> for ParserConfig2

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for ParserConfig2

source§

impl StructuralEq for ParserConfig2

source§

impl StructuralPartialEq for ParserConfig2

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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.