From bdc55b5958596ee39f29eeca99ec5e0d1425edf1 Mon Sep 17 00:00:00 2001 From: Edward Barnard Date: Thu, 20 Apr 2017 12:16:34 +0100 Subject: Replace rustc-serialize with base64 crate. --- src/lib.rs | 2 +- src/plist.rs | 21 --------------------- src/xml/reader.rs | 9 +++------ src/xml/writer.rs | 4 ++-- 4 files changed, 6 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 8a72ad3..74c2095 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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> { 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 EventReader { "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 PlistEventWriter for EventWriter { 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) => { -- cgit v1.2.3