Update serde to 0.9 (fixes #15325)

This commit is contained in:
Anthony Ramine 2017-02-10 02:35:26 +01:00
parent 26d6c96b18
commit fe3f4ff0c2
73 changed files with 630 additions and 604 deletions

View file

@ -16,9 +16,8 @@ use devtools_traits::EvaluateJSReply::{NullValue, NumberValue, VoidValue};
use ipc_channel::ipc::{self, IpcSender};
use msg::constellation_msg::PipelineId;
use protocol::JsonPacketStream;
use serde_json::{self, Value};
use serde_json::{self, Map, Number, Value};
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::net::TcpStream;
trait EncodableConsoleMessage {
@ -50,7 +49,7 @@ struct StartedListenersReply {
#[derive(Serialize)]
struct GetCachedMessagesReply {
from: String,
messages: Vec<BTreeMap<String, Value>>,
messages: Vec<Map<String, Value>>,
}
#[derive(Serialize)]
@ -98,7 +97,7 @@ impl Actor for ConsoleActor {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &str,
msg: &BTreeMap<String, Value>,
msg: &Map<String, Value>,
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"getCachedMessages" => {
@ -182,46 +181,46 @@ impl Actor for ConsoleActor {
//TODO: extract conversion into protocol module or some other useful place
let result = match try!(port.recv().map_err(|_| ())) {
VoidValue => {
let mut m = BTreeMap::new();
m.insert("type".to_owned(), serde_json::to_value("undefined"));
let mut m = Map::new();
m.insert("type".to_owned(), Value::String("undefined".to_owned()));
Value::Object(m)
}
NullValue => {
let mut m = BTreeMap::new();
m.insert("type".to_owned(), serde_json::to_value("null"));
let mut m = Map::new();
m.insert("type".to_owned(), Value::String("null".to_owned()));
Value::Object(m)
}
BooleanValue(val) => Value::Bool(val),
NumberValue(val) => {
if val.is_nan() {
let mut m = BTreeMap::new();
m.insert("type".to_owned(), serde_json::to_value("NaN"));
let mut m = Map::new();
m.insert("type".to_owned(), Value::String("NaN".to_owned()));
Value::Object(m)
} else if val.is_infinite() {
let mut m = BTreeMap::new();
let mut m = Map::new();
if val < 0. {
m.insert("type".to_owned(), serde_json::to_value("-Infinity"));
m.insert("type".to_owned(), Value::String("-Infinity".to_owned()));
} else {
m.insert("type".to_owned(), serde_json::to_value("Infinity"));
m.insert("type".to_owned(), Value::String("Infinity".to_owned()));
}
Value::Object(m)
} else if val == 0. && val.is_sign_negative() {
let mut m = BTreeMap::new();
m.insert("type".to_owned(), serde_json::to_value("-0"));
let mut m = Map::new();
m.insert("type".to_owned(), Value::String("-0".to_owned()));
Value::Object(m)
} else {
serde_json::to_value(&val)
Value::Number(Number::from_f64(val).unwrap())
}
}
StringValue(s) => Value::String(s),
ActorValue { class, uuid } => {
//TODO: make initial ActorValue message include these properties?
let mut m = BTreeMap::new();
let mut m = Map::new();
let actor = ObjectActor::new(registry, uuid);
m.insert("type".to_owned(), serde_json::to_value("object"));
m.insert("class".to_owned(), serde_json::to_value(&class));
m.insert("actor".to_owned(), serde_json::to_value(&actor));
m.insert("type".to_owned(), Value::String("object".to_owned()));
m.insert("class".to_owned(), Value::String(class));
m.insert("actor".to_owned(), Value::String(actor));
m.insert("extensible".to_owned(), Value::Bool(true));
m.insert("frozen".to_owned(), Value::Bool(false));
m.insert("sealed".to_owned(), Value::Bool(false));
@ -235,9 +234,9 @@ impl Actor for ConsoleActor {
input: input,
result: result,
timestamp: 0,
exception: Value::Object(BTreeMap::new()),
exception: Value::Object(Map::new()),
exceptionMessage: "".to_owned(),
helperResult: Value::Object(BTreeMap::new()),
helperResult: Value::Object(Map::new()),
};
stream.write_json_packet(&msg);
ActorMessageStatus::Processed

View file

@ -7,8 +7,7 @@ use actors::timeline::HighResolutionStamp;
use devtools_traits::DevtoolScriptControlMsg;
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::PipelineId;
use serde_json::Value;
use std::collections::BTreeMap;
use serde_json::{Map, Value};
use std::mem;
use std::net::TcpStream;
use time::precise_time_ns;
@ -31,7 +30,7 @@ impl Actor for FramerateActor {
fn handle_message(&self,
_registry: &ActorRegistry,
_msg_type: &str,
_msg: &BTreeMap<String, Value>,
_msg: &Map<String, Value>,
_stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(ActorMessageStatus::Ignored)
}

View file

@ -12,9 +12,8 @@ use devtools_traits::DevtoolScriptControlMsg::{GetLayout, ModifyAttribute};
use ipc_channel::ipc::{self, IpcSender};
use msg::constellation_msg::PipelineId;
use protocol::JsonPacketStream;
use serde_json::{self, Value};
use serde_json::{self, Map, Value};
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::net::TcpStream;
pub struct InspectorActor {
@ -65,7 +64,7 @@ impl Actor for HighlighterActor {
fn handle_message(&self,
_registry: &ActorRegistry,
msg_type: &str,
_msg: &BTreeMap<String, Value>,
_msg: &Map<String, Value>,
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"showBoxModel" => {
@ -102,7 +101,7 @@ impl Actor for NodeActor {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &str,
msg: &BTreeMap<String, Value>,
msg: &Map<String, Value>,
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"modifyAttributes" => {
@ -276,7 +275,7 @@ impl Actor for WalkerActor {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &str,
msg: &BTreeMap<String, Value>,
msg: &Map<String, Value>,
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"querySelector" => {
@ -451,7 +450,7 @@ impl Actor for PageStyleActor {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &str,
msg: &BTreeMap<String, Value>,
msg: &Map<String, Value>,
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"getApplied" => {
@ -503,7 +502,7 @@ impl Actor for PageStyleActor {
zIndex: zIndex,
boxSizing: boxSizing,
autoMargins: if auto_margins {
let mut m = BTreeMap::new();
let mut m = Map::new();
let auto = serde_json::value::Value::String("auto".to_owned());
if autoMargins.top { m.insert("top".to_owned(), auto.clone()); }
if autoMargins.right { m.insert("right".to_owned(), auto.clone()); }
@ -547,7 +546,7 @@ impl Actor for InspectorActor {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &str,
_msg: &BTreeMap<String, Value>,
_msg: &Map<String, Value>,
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"getWalker" => {

View file

@ -3,8 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use actor::{Actor, ActorMessageStatus, ActorRegistry};
use serde_json::Value;
use std::collections::BTreeMap;
use serde_json::{Map, Value};
use std::net::TcpStream;
#[derive(Serialize)]
@ -32,7 +31,7 @@ impl Actor for MemoryActor {
fn handle_message(&self,
_registry: &ActorRegistry,
_msg_type: &str,
_msg: &BTreeMap<String, Value>,
_msg: &Map<String, Value>,
_stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(ActorMessageStatus::Ignored)
}

View file

@ -16,9 +16,8 @@ use hyper::header::Headers;
use hyper::http::RawStatus;
use hyper::method::Method;
use protocol::JsonPacketStream;
use serde_json::Value;
use serde_json::{Map, Value};
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::net::TcpStream;
use time;
use time::Tm;
@ -185,7 +184,7 @@ impl Actor for NetworkEventActor {
fn handle_message(&self,
_registry: &ActorRegistry,
msg_type: &str,
_msg: &BTreeMap<String, Value>,
_msg: &Map<String, Value>,
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"getRequestHeaders" => {

View file

@ -3,8 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use actor::{Actor, ActorMessageStatus, ActorRegistry};
use serde_json::Value;
use std::collections::BTreeMap;
use serde_json::{Map, Value};
use std::net::TcpStream;
pub struct ObjectActor {
@ -19,7 +18,7 @@ impl Actor for ObjectActor {
fn handle_message(&self,
_: &ActorRegistry,
_: &str,
_: &BTreeMap<String, Value>,
_: &Map<String, Value>,
_: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(ActorMessageStatus::Ignored)
}

View file

@ -4,8 +4,7 @@
use actor::{Actor, ActorMessageStatus, ActorRegistry};
use protocol::{ActorDescription, JsonPacketStream, Method};
use serde_json::Value;
use std::collections::BTreeMap;
use serde_json::{Map, Value};
use std::net::TcpStream;
pub struct PerformanceActor {
@ -55,7 +54,7 @@ impl Actor for PerformanceActor {
fn handle_message(&self,
_registry: &ActorRegistry,
msg_type: &str,
_msg: &BTreeMap<String, Value>,
_msg: &Map<String, Value>,
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"connect" => {

View file

@ -3,8 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use actor::{Actor, ActorMessageStatus, ActorRegistry};
use serde_json::Value;
use std::collections::BTreeMap;
use serde_json::{Map, Value};
use std::net::TcpStream;
pub struct ProfilerActor {
@ -19,7 +18,7 @@ impl Actor for ProfilerActor {
fn handle_message(&self,
_registry: &ActorRegistry,
_msg_type: &str,
_msg: &BTreeMap<String, Value>,
_msg: &Map<String, Value>,
_stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(ActorMessageStatus::Ignored)
}

View file

@ -11,8 +11,7 @@ use actor::{Actor, ActorMessageStatus, ActorRegistry};
use actors::performance::PerformanceActor;
use actors::tab::{TabActor, TabActorMsg};
use protocol::{ActorDescription, JsonPacketStream};
use serde_json::Value;
use std::collections::BTreeMap;
use serde_json::{Map, Value};
use std::net::TcpStream;
#[derive(Serialize)]
@ -69,7 +68,7 @@ impl Actor for RootActor {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &str,
_msg: &BTreeMap<String, Value>,
_msg: &Map<String, Value>,
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"listAddons" => {

View file

@ -11,8 +11,7 @@ use actor::{Actor, ActorMessageStatus, ActorRegistry};
use actors::console::ConsoleActor;
use devtools_traits::DevtoolScriptControlMsg::{self, WantsLiveNotifications};
use protocol::JsonPacketStream;
use serde_json::Value;
use std::collections::BTreeMap;
use serde_json::{Map, Value};
use std::net::TcpStream;
#[derive(Serialize)]
@ -88,7 +87,7 @@ impl Actor for TabActor {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &str,
msg: &BTreeMap<String, Value>,
msg: &Map<String, Value>,
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"reconfigure" => {

View file

@ -4,8 +4,7 @@
use actor::{Actor, ActorMessageStatus, ActorRegistry};
use protocol::JsonPacketStream;
use serde_json::Value;
use std::collections::BTreeMap;
use serde_json::{Map, Value};
use std::net::TcpStream;
#[derive(Serialize)]
@ -68,7 +67,7 @@ impl Actor for ThreadActor {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &str,
_msg: &BTreeMap<String, Value>,
_msg: &Map<String, Value>,
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"attach" => {

View file

@ -12,9 +12,8 @@ use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use msg::constellation_msg::PipelineId;
use protocol::JsonPacketStream;
use serde::{Serialize, Serializer};
use serde_json::Value;
use serde_json::{Map, Value};
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::net::TcpStream;
use std::sync::{Arc, Mutex};
use std::thread;
@ -115,7 +114,7 @@ impl HighResolutionStamp {
}
impl Serialize for HighResolutionStamp {
fn serialize<S: Serializer>(&self, s: &mut S) -> Result<(), S::Error> {
fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
self.0.serialize(s)
}
}
@ -175,7 +174,7 @@ impl Actor for TimelineActor {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &str,
msg: &BTreeMap<String, Value>,
msg: &Map<String, Value>,
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"start" => {

View file

@ -4,8 +4,7 @@
use actor::{Actor, ActorMessageStatus, ActorRegistry};
use devtools_traits::WorkerId;
use serde_json::Value;
use std::collections::BTreeMap;
use serde_json::{Map, Value};
use std::net::TcpStream;
pub struct WorkerActor {
@ -21,7 +20,7 @@ impl Actor for WorkerActor {
fn handle_message(&self,
_: &ActorRegistry,
_: &str,
_: &BTreeMap<String, Value>,
_: &Map<String, Value>,
_: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(ActorMessageStatus::Processed)
}