diff options
| author | Edward Barnard | 2017-04-20 12:16:34 +0100 |
|---|---|---|
| committer | Edward Barnard | 2017-04-20 12:16:34 +0100 |
| commit | bdc55b5958596ee39f29eeca99ec5e0d1425edf1 (patch) | |
| tree | 29c8747fc7b5bf9e427e55cc223bae1b1f7a46e2 /src | |
| parent | 2e7bd78be40b04ff12379b6aeb739f7172ab11c9 (diff) | |
| download | rust-plist-bdc55b5958596ee39f29eeca99ec5e0d1425edf1.tar.bz2 | |
Replace rustc-serialize with base64 crate.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 2 | ||||
| -rw-r--r-- | src/plist.rs | 21 | ||||
| -rw-r--r-- | src/xml/reader.rs | 9 | ||||
| -rw-r--r-- | src/xml/writer.rs | 4 |
4 files changed, 6 insertions, 30 deletions
@@ -49,9 +49,9 @@ //! let info: Info = deserialize(file).unwrap(); //! ``` +extern crate base64; extern crate byteorder; extern crate chrono; -extern crate rustc_serialize; extern crate xml as xml_rs; pub mod binary; diff --git a/src/plist.rs b/src/plist.rs index f84de6f..14a16ce 100644 --- a/src/plist.rs +++ b/src/plist.rs @@ -1,5 +1,3 @@ -use rustc_serialize::base64::{STANDARD, ToBase64}; -use rustc_serialize::json::Json as RustcJson; use std::collections::BTreeMap; use std::io::{Read, Seek}; @@ -63,25 +61,6 @@ impl Plist { } } - pub fn into_rustc_serialize_json(self) -> RustcJson { - match self { - Plist::Array(value) => { - RustcJson::Array(value.into_iter().map(|p| p.into_rustc_serialize_json()).collect()) - } - Plist::Dictionary(value) => { - RustcJson::Object(value.into_iter() - .map(|(k, v)| (k, v.into_rustc_serialize_json())) - .collect()) - } - Plist::Boolean(value) => RustcJson::Boolean(value), - Plist::Data(value) => RustcJson::String(value.to_base64(STANDARD)), - Plist::Date(value) => RustcJson::String(value.to_string()), - Plist::Real(value) => RustcJson::F64(value), - Plist::Integer(value) => RustcJson::I64(value), - Plist::String(value) => RustcJson::String(value), - } - } - /// If the `Plist` is an Array, returns the associated Vec. /// Returns None otherwise. pub fn as_array(&self) -> Option<&Vec<Plist>> { diff --git a/src/xml/reader.rs b/src/xml/reader.rs index 00b3bc4..4a236fa 100644 --- a/src/xml/reader.rs +++ b/src/xml/reader.rs @@ -1,4 +1,4 @@ -use rustc_serialize::base64::FromBase64; +use base64; use std::io::Read; use std::str::FromStr; use xml_rs::reader::{EventReader as XmlEventReader, ParserConfig, XmlEvent}; @@ -66,11 +66,8 @@ impl<R: Read> EventReader<R> { "false" => return Some(Ok(PlistEvent::BooleanValue(false))), "data" => { return Some(self.read_content(|s| { - let s: String = s.replace(" ", "").replace("\t", ""); - match FromBase64::from_base64(&s[..]) { - Ok(b) => Ok(PlistEvent::DataValue(b)), - Err(_) => Err(Error::InvalidData), - } + let data = base64::decode_ws(&s).map_err(|_| Error::InvalidData)?; + Ok(PlistEvent::DataValue(data)) })) } "date" => { diff --git a/src/xml/writer.rs b/src/xml/writer.rs index 02c57db..a3bfb53 100644 --- a/src/xml/writer.rs +++ b/src/xml/writer.rs @@ -1,4 +1,4 @@ -use rustc_serialize::base64::{MIME, ToBase64}; +use base64; use std::borrow::Cow; use std::io::Write; use xml_rs::attribute::Attribute; @@ -162,7 +162,7 @@ impl<W: Write> PlistEventWriter for EventWriter<W> { try!(self.end_element("false")); } PlistEvent::DataValue(ref value) => { - let base64_data = value.to_base64(MIME); + let base64_data = base64::encode(&value); try!(self.write_element_and_value("data", &base64_data)); } PlistEvent::DateValue(ref value) => { |
