Skip to content

Commit

Permalink
Remove rustc-serialize from the dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Eijebong committed Nov 7, 2018
1 parent da2d9b2 commit 221199d
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 69 deletions.
47 changes: 23 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/config/Cargo.toml
Expand Up @@ -19,8 +19,8 @@ getopts = "0.2.11"
lazy_static = "1"
log = "0.4"
num_cpus = "1.1.0"
rustc-serialize = "0.3"
serde = "1.0"
serde_json = "1.0"
servo_geometry = {path = "../geometry"}
servo_url = {path = "../url"}
url = "1.2"
Expand Down
2 changes: 1 addition & 1 deletion components/config/lib.rs
Expand Up @@ -14,9 +14,9 @@ extern crate lazy_static;
#[macro_use]
extern crate log;
extern crate num_cpus;
extern crate rustc_serialize;
#[macro_use]
extern crate serde;
extern crate serde_json;
extern crate servo_geometry;
extern crate servo_url;
extern crate url;
Expand Down
41 changes: 14 additions & 27 deletions components/config/prefs.rs
Expand Up @@ -6,7 +6,7 @@ use crate::basedir::default_config_dir;
use crate::opts;
use embedder_traits::resources::{self, Resource};
use num_cpus;
use rustc_serialize::json::{Json, ToJson};
use serde_json::{self, Value};
use std::borrow::ToOwned;
use std::cmp::max;
use std::collections::HashMap;
Expand Down Expand Up @@ -34,13 +34,17 @@ pub enum PrefValue {
}

impl PrefValue {
pub fn from_json(data: Json) -> Result<PrefValue, ()> {
pub fn from_json(data: Value) -> Result<PrefValue, ()> {
let value = match data {
Json::Boolean(x) => PrefValue::Boolean(x),
Json::String(x) => PrefValue::String(x),
Json::F64(x) => PrefValue::Number(x),
Json::I64(x) => PrefValue::Number(x as f64),
Json::U64(x) => PrefValue::Number(x as f64),
Value::Bool(x) => PrefValue::Boolean(x),
Value::String(x) => PrefValue::String(x),
Value::Number(x) => {
if let Some(v) = x.as_f64() {
PrefValue::Number(v)
} else {
return Err(());
}
},
_ => return Err(()),
};
Ok(value)
Expand Down Expand Up @@ -75,17 +79,6 @@ impl PrefValue {
}
}

impl ToJson for PrefValue {
fn to_json(&self) -> Json {
match *self {
PrefValue::Boolean(x) => Json::Boolean(x),
PrefValue::String(ref x) => Json::String(x.clone()),
PrefValue::Number(x) => Json::F64(x),
PrefValue::Missing => Json::Null,
}
}
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum Pref {
NoDefault(Arc<PrefValue>),
Expand All @@ -101,7 +94,7 @@ impl Pref {
Pref::WithDefault(Arc::new(value), None)
}

fn from_json(data: Json) -> Result<Pref, ()> {
fn from_json(data: Value) -> Result<Pref, ()> {
let value = PrefValue::from_json(data)?;
Ok(Pref::new_default(value))
}
Expand All @@ -126,12 +119,6 @@ impl Pref {
}
}

impl ToJson for Pref {
fn to_json(&self) -> Json {
self.value().to_json()
}
}

pub fn default_prefs() -> Preferences {
let prefs = Preferences(Arc::new(RwLock::new(HashMap::new())));
prefs.set(
Expand All @@ -142,13 +129,13 @@ pub fn default_prefs() -> Preferences {
}

pub fn read_prefs(txt: &str) -> Result<HashMap<String, Pref>, ()> {
let json = Json::from_str(txt).or_else(|e| {
let json: Value = serde_json::from_str(txt).or_else(|e| {
println!("Ignoring invalid JSON in preferences: {:?}.", e);
Err(())
})?;

let mut prefs = HashMap::new();
if let Json::Object(obj) = json {
if let Value::Object(obj) = json {
for (name, value) in obj.into_iter() {
match Pref::from_json(value) {
Ok(x) => {
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/document.rs
Expand Up @@ -4420,7 +4420,7 @@ impl DocumentMethods for Document {
}

fn update_with_current_time_ms(marker: &Cell<u64>) {
if marker.get() == Default::default() {
if marker.get() == 0 {
let time = time::get_time();
let current_time_ms = time.sec * 1000 + time.nsec as i64 / 1000000;
marker.set(current_time_ms as u64);
Expand Down
1 change: 0 additions & 1 deletion components/script_traits/Cargo.toml
Expand Up @@ -29,7 +29,6 @@ malloc_size_of_derive = { path = "../malloc_size_of_derive" }
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
profile_traits = {path = "../profile_traits"}
rustc-serialize = "0.3.4"
serde = "1.0"
servo_atoms = {path = "../atoms"}
servo_channel = {path = "../channel"}
Expand Down
1 change: 0 additions & 1 deletion components/script_traits/lib.rs
Expand Up @@ -29,7 +29,6 @@ extern crate malloc_size_of_derive;
extern crate msg;
extern crate net_traits;
extern crate profile_traits;
extern crate rustc_serialize;
#[macro_use]
extern crate serde;
extern crate servo_atoms;
Expand Down
13 changes: 0 additions & 13 deletions components/script_traits/webdriver_msg.rs
Expand Up @@ -9,7 +9,6 @@ use euclid::Rect;
use hyper_serde::Serde;
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::BrowsingContextId;
use rustc_serialize::json::{Json, ToJson};
use servo_url::ServoUrl;

#[derive(Debug, Deserialize, Serialize)]
Expand Down Expand Up @@ -75,18 +74,6 @@ pub enum WebDriverFrameId {
Parent,
}

impl ToJson for WebDriverJSValue {
fn to_json(&self) -> Json {
match *self {
WebDriverJSValue::Undefined => Json::Null,
WebDriverJSValue::Null => Json::Null,
WebDriverJSValue::Boolean(ref x) => x.to_json(),
WebDriverJSValue::Number(ref x) => x.to_json(),
WebDriverJSValue::String(ref x) => x.to_json(),
}
}
}

#[derive(Debug, Deserialize, Serialize)]
pub enum LoadStatus {
LoadComplete,
Expand Down

0 comments on commit 221199d

Please sign in to comment.