aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Barnard2017-02-22 10:27:48 +0000
committerEdward Barnard2017-02-22 10:27:48 +0000
commit364edcccfa907c0182bf085e1fbc3fc49389c54c (patch)
treede8f784eafa8a687cc3548987f1e7484e9ed7769
parent6955747b8fd89025424c2c3feeb568d8fa08e880 (diff)
downloadrust-plist-364edcccfa907c0182bf085e1fbc3fc49389c54c.tar.bz2
Use builder pattern for xml_rs config structs.
-rw-r--r--src/xml/reader.rs15
-rw-r--r--src/xml/writer.rs20
2 files changed, 15 insertions, 20 deletions
diff --git a/src/xml/reader.rs b/src/xml/reader.rs
index 265ac11..d7ec99e 100644
--- a/src/xml/reader.rs
+++ b/src/xml/reader.rs
@@ -3,7 +3,6 @@ use chrono::format::ParseError as ChronoParseError;
use rustc_serialize::base64::FromBase64;
use std::io::Read;
use std::str::FromStr;
-use std::collections::HashMap;
use xml_rs::reader::{EventReader as XmlEventReader, ParserConfig, XmlEvent};
use {Error, Result, PlistEvent};
@@ -23,14 +22,12 @@ pub struct EventReader<R: Read> {
impl<R: Read> EventReader<R> {
pub fn new(reader: R) -> EventReader<R> {
- let config = ParserConfig {
- trim_whitespace: false,
- whitespace_to_characters: true,
- cdata_to_characters: true,
- ignore_comments: true,
- coalesce_characters: true,
- extra_entities: HashMap::default(),
- };
+ let config = ParserConfig::new()
+ .trim_whitespace(false)
+ .whitespace_to_characters(true)
+ .cdata_to_characters(true)
+ .ignore_comments(true)
+ .coalesce_characters(true);
EventReader {
xml_reader: XmlEventReader::new_with_config(reader, config),
diff --git a/src/xml/writer.rs b/src/xml/writer.rs
index bf3432a..400663d 100644
--- a/src/xml/writer.rs
+++ b/src/xml/writer.rs
@@ -38,17 +38,15 @@ pub struct EventWriter<W: Write> {
impl<W: Write> EventWriter<W> {
pub fn new(writer: W) -> EventWriter<W> {
- let config = EmitterConfig {
- line_separator: "\n".into(),
- indent_string: " ".into(),
- perform_indent: true,
- perform_escaping: true,
- write_document_declaration: true,
- normalize_empty_elements: true,
- cdata_to_characters: true,
- keep_element_names_stack: false,
- autopad_comments: true,
- };
+ let config = EmitterConfig::new()
+ .line_separator("\n")
+ .indent_string(" ")
+ .perform_indent(true)
+ .write_document_declaration(true)
+ .normalize_empty_elements(true)
+ .cdata_to_characters(true)
+ .keep_element_names_stack(false)
+ .autopad_comments(true);
EventWriter {
xml_writer: XmlEventWriter::new_with_config(writer, config),