Stop calling to_string() in devtools.

This commit is contained in:
Ms2ger 2015-09-02 19:50:41 +02:00
parent 62a98e4918
commit 1257a33394
9 changed files with 68 additions and 68 deletions

View file

@ -99,9 +99,9 @@ impl ActorRegistry {
pub fn script_to_actor(&self, script_id: String) -> String { pub fn script_to_actor(&self, script_id: String) -> String {
if script_id.is_empty() { if script_id.is_empty() {
return "".to_string(); return "".to_owned();
} }
self.script_actors.borrow().get(&script_id).unwrap().to_string() self.script_actors.borrow().get(&script_id).unwrap().clone()
} }
pub fn script_actor_registered(&self, script_id: String) -> bool { pub fn script_actor_registered(&self, script_id: String) -> bool {
@ -112,7 +112,7 @@ impl ActorRegistry {
for (key, value) in &*self.script_actors.borrow() { for (key, value) in &*self.script_actors.borrow() {
println!("checking {}", value); println!("checking {}", value);
if *value == actor { if *value == actor {
return key.to_string(); return key.to_owned();
} }
} }
panic!("couldn't find actor named {}", actor) panic!("couldn't find actor named {}", actor)
@ -127,7 +127,7 @@ impl ActorRegistry {
/// Add an actor to the registry of known actors that can receive messages. /// Add an actor to the registry of known actors that can receive messages.
pub fn register(&mut self, actor: Box<Actor + Send>) { pub fn register(&mut self, actor: Box<Actor + Send>) {
self.actors.insert(actor.name().to_string(), actor); self.actors.insert(actor.name(), actor);
} }
pub fn register_later(&self, actor: Box<Actor + Send>) { pub fn register_later(&self, actor: Box<Actor + Send>) {
@ -137,13 +137,13 @@ impl ActorRegistry {
/// Find an actor by registered name /// Find an actor by registered name
pub fn find<'a, T: Any>(&'a self, name: &str) -> &'a T { pub fn find<'a, T: Any>(&'a self, name: &str) -> &'a T {
let actor = self.actors.get(&name.to_string()).unwrap(); let actor = self.actors.get(name).unwrap();
actor.actor_as_any().downcast_ref::<T>().unwrap() actor.actor_as_any().downcast_ref::<T>().unwrap()
} }
/// Find an actor by registered name /// Find an actor by registered name
pub fn find_mut<'a, T: Any>(&'a mut self, name: &str) -> &'a mut T { pub fn find_mut<'a, T: Any>(&'a mut self, name: &str) -> &'a mut T {
let actor = self.actors.get_mut(&name.to_string()).unwrap(); let actor = self.actors.get_mut(name).unwrap();
actor.actor_as_any_mut().downcast_mut::<T>().unwrap() actor.actor_as_any_mut().downcast_mut::<T>().unwrap()
} }
@ -155,11 +155,11 @@ impl ActorRegistry {
-> Result<(), ()> { -> Result<(), ()> {
let to = msg.get("to").unwrap().as_string().unwrap(); let to = msg.get("to").unwrap().as_string().unwrap();
match self.actors.get(&to.to_string()) { match self.actors.get(to) {
None => println!("message received for unknown actor \"{}\"", to), None => println!("message received for unknown actor \"{}\"", to),
Some(actor) => { Some(actor) => {
let msg_type = msg.get("type").unwrap().as_string().unwrap(); let msg_type = msg.get("type").unwrap().as_string().unwrap();
if try!(actor.handle_message(self, &msg_type.to_string(), msg, stream)) if try!(actor.handle_message(self, msg_type, msg, stream))
!= ActorMessageStatus::Processed { != ActorMessageStatus::Processed {
println!("unexpected message type \"{}\" found for actor \"{}\"", println!("unexpected message type \"{}\" found for actor \"{}\"",
msg_type, to); msg_type, to);
@ -168,7 +168,7 @@ impl ActorRegistry {
} }
let new_actors = replace(&mut *self.new_actors.borrow_mut(), vec!()); let new_actors = replace(&mut *self.new_actors.borrow_mut(), vec!());
for actor in new_actors.into_iter() { for actor in new_actors.into_iter() {
self.actors.insert(actor.name().to_string(), actor); self.actors.insert(actor.name().to_owned(), actor);
} }
let old_actors = replace(&mut *self.old_actors.borrow_mut(), vec!()); let old_actors = replace(&mut *self.old_actors.borrow_mut(), vec!());

View file

@ -133,7 +133,7 @@ impl Actor for ConsoleActor {
from: self.name(), from: self.name(),
nativeConsoleAPI: true, nativeConsoleAPI: true,
startedListeners: startedListeners:
vec!("PageError".to_string(), "ConsoleAPI".to_string()), vec!("PageError".to_owned(), "ConsoleAPI".to_owned()),
traits: StartedListenersTraits { traits: StartedListenersTraits {
customNetworkRequest: true, customNetworkRequest: true,
} }
@ -146,12 +146,12 @@ impl Actor for ConsoleActor {
//TODO: actually implement listener filters that support starting/stopping //TODO: actually implement listener filters that support starting/stopping
let msg = StopListenersReply { let msg = StopListenersReply {
from: self.name(), from: self.name(),
stoppedListeners: msg.get(&"listeners".to_string()) stoppedListeners: msg.get("listeners")
.unwrap() .unwrap()
.as_array() .as_array()
.unwrap_or(&vec!()) .unwrap_or(&vec!())
.iter() .iter()
.map(|listener| listener.as_string().unwrap().to_string()) .map(|listener| listener.as_string().unwrap().to_owned())
.collect(), .collect(),
}; };
stream.write_json_packet(&msg); stream.write_json_packet(&msg);
@ -164,14 +164,14 @@ impl Actor for ConsoleActor {
let msg = AutocompleteReply { let msg = AutocompleteReply {
from: self.name(), from: self.name(),
matches: vec!(), matches: vec!(),
matchProp: "".to_string(), matchProp: "".to_owned(),
}; };
stream.write_json_packet(&msg); stream.write_json_packet(&msg);
ActorMessageStatus::Processed ActorMessageStatus::Processed
} }
"evaluateJS" => { "evaluateJS" => {
let input = msg.get(&"text".to_string()).unwrap().as_string().unwrap().to_string(); let input = msg.get("text").unwrap().as_string().unwrap().to_owned();
let (chan, port) = ipc::channel().unwrap(); let (chan, port) = ipc::channel().unwrap();
self.script_chan.send(DevtoolScriptControlMsg::EvaluateJS( self.script_chan.send(DevtoolScriptControlMsg::EvaluateJS(
self.pipeline, input.clone(), chan)).unwrap(); self.pipeline, input.clone(), chan)).unwrap();
@ -180,31 +180,31 @@ impl Actor for ConsoleActor {
let result = match try!(port.recv().map_err(|_| ())) { let result = match try!(port.recv().map_err(|_| ())) {
VoidValue => { VoidValue => {
let mut m = BTreeMap::new(); let mut m = BTreeMap::new();
m.insert("type".to_string(), "undefined".to_string().to_json()); m.insert("type".to_owned(), "undefined".to_owned().to_json());
Json::Object(m) Json::Object(m)
} }
NullValue => { NullValue => {
let mut m = BTreeMap::new(); let mut m = BTreeMap::new();
m.insert("type".to_string(), "null".to_string().to_json()); m.insert("type".to_owned(), "null".to_owned().to_json());
Json::Object(m) Json::Object(m)
} }
BooleanValue(val) => val.to_json(), BooleanValue(val) => val.to_json(),
NumberValue(val) => { NumberValue(val) => {
if val.is_nan() { if val.is_nan() {
let mut m = BTreeMap::new(); let mut m = BTreeMap::new();
m.insert("type".to_string(), "NaN".to_string().to_json()); m.insert("type".to_owned(), "NaN".to_owned().to_json());
Json::Object(m) Json::Object(m)
} else if val.is_infinite() { } else if val.is_infinite() {
let mut m = BTreeMap::new(); let mut m = BTreeMap::new();
if val < 0. { if val < 0. {
m.insert("type".to_string(), "-Infinity".to_string().to_json()); m.insert("type".to_owned(), "-Infinity".to_owned().to_json());
} else { } else {
m.insert("type".to_string(), "Infinity".to_string().to_json()); m.insert("type".to_owned(), "Infinity".to_owned().to_json());
} }
Json::Object(m) Json::Object(m)
} else if val == 0. && val.is_sign_negative() { } else if val == 0. && val.is_sign_negative() {
let mut m = BTreeMap::new(); let mut m = BTreeMap::new();
m.insert("type".to_string(), "-0".to_string().to_json()); m.insert("type".to_owned(), "-0".to_owned().to_json());
Json::Object(m) Json::Object(m)
} else { } else {
val.to_json() val.to_json()
@ -216,12 +216,12 @@ impl Actor for ConsoleActor {
let mut m = BTreeMap::new(); let mut m = BTreeMap::new();
let actor = ObjectActor::new(registry, uuid); let actor = ObjectActor::new(registry, uuid);
m.insert("type".to_string(), "object".to_string().to_json()); m.insert("type".to_owned(), "object".to_owned().to_json());
m.insert("class".to_string(), class.to_json()); m.insert("class".to_owned(), class.to_json());
m.insert("actor".to_string(), actor.to_json()); m.insert("actor".to_owned(), actor.to_json());
m.insert("extensible".to_string(), true.to_json()); m.insert("extensible".to_owned(), true.to_json());
m.insert("frozen".to_string(), false.to_json()); m.insert("frozen".to_owned(), false.to_json());
m.insert("sealed".to_string(), false.to_json()); m.insert("sealed".to_owned(), false.to_json());
Json::Object(m) Json::Object(m)
} }
}; };
@ -233,7 +233,7 @@ impl Actor for ConsoleActor {
result: result, result: result,
timestamp: 0, timestamp: 0,
exception: Json::Object(BTreeMap::new()), exception: Json::Object(BTreeMap::new()),
exceptionMessage: "".to_string(), exceptionMessage: "".to_owned(),
helperResult: Json::Object(BTreeMap::new()), helperResult: Json::Object(BTreeMap::new()),
}; };
stream.write_json_packet(&msg); stream.write_json_packet(&msg);

View file

@ -109,14 +109,14 @@ impl Actor for NodeActor {
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> { stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type { Ok(match msg_type {
"modifyAttributes" => { "modifyAttributes" => {
let target = msg.get(&"to".to_string()).unwrap().as_string().unwrap(); let target = msg.get("to").unwrap().as_string().unwrap();
let mods = msg.get(&"modifications".to_string()).unwrap().as_array().unwrap(); let mods = msg.get("modifications").unwrap().as_array().unwrap();
let modifications = mods.iter().map(|json_mod| { let modifications = mods.iter().map(|json_mod| {
json::decode(&json_mod.to_string()).unwrap() json::decode(&json_mod.to_string()).unwrap()
}).collect(); }).collect();
self.script_chan.send(ModifyAttribute(self.pipeline, self.script_chan.send(ModifyAttribute(self.pipeline,
registry.actor_to_script(target.to_string()), registry.actor_to_script(target.to_owned()),
modifications)) modifications))
.unwrap(); .unwrap();
let reply = ModifyAttributeReply { let reply = ModifyAttributeReply {
@ -313,10 +313,10 @@ impl Actor for WalkerActor {
} }
"children" => { "children" => {
let target = msg.get(&"node".to_string()).unwrap().as_string().unwrap(); let target = msg.get("node").unwrap().as_string().unwrap();
let (tx, rx) = ipc::channel().unwrap(); let (tx, rx) = ipc::channel().unwrap();
self.script_chan.send(GetChildren(self.pipeline, self.script_chan.send(GetChildren(self.pipeline,
registry.actor_to_script(target.to_string()), registry.actor_to_script(target.to_owned()),
tx)) tx))
.unwrap(); .unwrap();
let children = rx.recv().unwrap(); let children = rx.recv().unwrap();
@ -452,15 +452,15 @@ impl Actor for PageStyleActor {
//TODO: query script for box layout properties of node (msg.node) //TODO: query script for box layout properties of node (msg.node)
"getLayout" => { "getLayout" => {
let target = msg.get(&"node".to_string()).unwrap().as_string().unwrap(); let target = msg.get("node").unwrap().as_string().unwrap();
let (tx, rx) = ipc::channel().unwrap(); let (tx, rx) = ipc::channel().unwrap();
self.script_chan.send(GetLayout(self.pipeline, self.script_chan.send(GetLayout(self.pipeline,
registry.actor_to_script(target.to_string()), registry.actor_to_script(target.to_owned()),
tx)) tx))
.unwrap(); .unwrap();
let ComputedNodeLayout { width, height } = rx.recv().unwrap(); let ComputedNodeLayout { width, height } = rx.recv().unwrap();
let auto_margins = msg.get(&"autoMargins".to_string()) let auto_margins = msg.get("autoMargins")
.and_then(&Json::as_boolean).unwrap_or(false); .and_then(&Json::as_boolean).unwrap_or(false);
//TODO: the remaining layout properties (margin, border, padding, position) //TODO: the remaining layout properties (margin, border, padding, position)
@ -473,10 +473,10 @@ impl Actor for PageStyleActor {
//TODO: real values like processMargins in //TODO: real values like processMargins in
// http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/styles.js // http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/styles.js
let mut m = BTreeMap::new(); let mut m = BTreeMap::new();
m.insert("top".to_string(), "auto".to_string().to_json()); m.insert("top".to_owned(), "auto".to_owned().to_json());
m.insert("bottom".to_string(), "auto".to_string().to_json()); m.insert("bottom".to_owned(), "auto".to_owned().to_json());
m.insert("left".to_string(), "auto".to_string().to_json()); m.insert("left".to_owned(), "auto".to_owned().to_json());
m.insert("right".to_string(), "auto".to_string().to_json()); m.insert("right".to_owned(), "auto".to_owned().to_json());
Json::Object(m) Json::Object(m)
} else { } else {
Json::Null Json::Null

View file

@ -82,7 +82,7 @@ impl Actor for NetworkEventActor {
from: self.name(), from: self.name(),
headers: Vec::new(), headers: Vec::new(),
headerSize: 10, headerSize: 10,
rawHeaders: "Raw headers".to_string(), rawHeaders: "Raw headers".to_owned(),
}; };
stream.write_json_packet(&msg); stream.write_json_packet(&msg);
ActorMessageStatus::Processed ActorMessageStatus::Processed
@ -144,7 +144,7 @@ impl NetworkEventActor {
actor: self.name(), actor: self.name(),
url: self.request.url.clone(), url: self.request.url.clone(),
method: format!("{}", self.request.method), method: format!("{}", self.request.method),
startedDateTime: "2015-04-22T20:47:08.545Z".to_string(), startedDateTime: "2015-04-22T20:47:08.545Z".to_owned(),
isXHR: false, isXHR: false,
private: false, private: false,
} }
@ -154,11 +154,11 @@ impl NetworkEventActor {
// TODO: Send the correct values for all these fields. // TODO: Send the correct values for all these fields.
// This is a fake message. // This is a fake message.
ResponseStartMsg { ResponseStartMsg {
httpVersion: "HTTP/1.1".to_string(), httpVersion: "HTTP/1.1".to_owned(),
remoteAddress: "63.245.217.43".to_string(), remoteAddress: "63.245.217.43".to_owned(),
remotePort: 443, remotePort: 443,
status: "200".to_string(), status: "200".to_owned(),
statusText: "OK".to_string(), statusText: "OK".to_owned(),
headersSize: 337, headersSize: 337,
discardResponseBody: true discardResponseBody: true
} }

View file

@ -48,7 +48,7 @@ pub struct RootActor {
impl Actor for RootActor { impl Actor for RootActor {
fn name(&self) -> String { fn name(&self) -> String {
"root".to_string() "root".to_owned()
} }
fn handle_message(&self, fn handle_message(&self,
@ -59,9 +59,9 @@ impl Actor for RootActor {
Ok(match msg_type { Ok(match msg_type {
"listAddons" => { "listAddons" => {
let actor = ErrorReply { let actor = ErrorReply {
from: "root".to_string(), from: "root".to_owned(),
error: "noAddons".to_string(), error: "noAddons".to_owned(),
message: "This root actor has no browser addons.".to_string(), message: "This root actor has no browser addons.".to_owned(),
}; };
stream.write_json_packet(&actor); stream.write_json_packet(&actor);
ActorMessageStatus::Processed ActorMessageStatus::Processed
@ -70,7 +70,7 @@ impl Actor for RootActor {
//https://wiki.mozilla.org/Remote_Debugging_Protocol#Listing_Browser_Tabs //https://wiki.mozilla.org/Remote_Debugging_Protocol#Listing_Browser_Tabs
"listTabs" => { "listTabs" => {
let actor = ListTabsReply { let actor = ListTabsReply {
from: "root".to_string(), from: "root".to_owned(),
selected: 0, selected: 0,
tabs: self.tabs.iter().map(|tab| { tabs: self.tabs.iter().map(|tab| {
registry.find::<TabActor>(tab).encodable() registry.find::<TabActor>(tab).encodable()
@ -88,12 +88,12 @@ impl Actor for RootActor {
impl RootActor { impl RootActor {
pub fn encodable(&self) -> RootActorMsg { pub fn encodable(&self) -> RootActorMsg {
RootActorMsg { RootActorMsg {
from: "root".to_string(), from: "root".to_owned(),
applicationType: "browser".to_string(), applicationType: "browser".to_owned(),
traits: ActorTraits { traits: ActorTraits {
sources: true, sources: true,
highlightable: true, highlightable: true,
customHighlighters: vec!("BoxModelHighlighter".to_string()), customHighlighters: vec!("BoxModelHighlighter".to_owned()),
}, },
} }
} }

View file

@ -98,7 +98,7 @@ impl Actor for TabActor {
"attach" => { "attach" => {
let msg = TabAttachedReply { let msg = TabAttachedReply {
from: self.name(), from: self.name(),
__type__: "tabAttached".to_string(), __type__: "tabAttached".to_owned(),
threadActor: self.name(), threadActor: self.name(),
cacheDisabled: false, cacheDisabled: false,
javascriptEnabled: true, javascriptEnabled: true,
@ -117,7 +117,7 @@ impl Actor for TabActor {
"detach" => { "detach" => {
let msg = TabDetachedReply { let msg = TabDetachedReply {
from: self.name(), from: self.name(),
__type__: "detached".to_string(), __type__: "detached".to_owned(),
}; };
let console_actor = registry.find::<ConsoleActor>(&self.console); let console_actor = registry.find::<ConsoleActor>(&self.console);
console_actor.streams.borrow_mut().pop(); console_actor.streams.borrow_mut().pop();

View file

@ -147,7 +147,7 @@ impl TimelineActor {
return; return;
} }
task::spawn_named("PullTimelineMarkers".to_string(), move || { task::spawn_named("PullTimelineMarkers".to_owned(), move || {
loop { loop {
if !*is_recording.lock().unwrap() { if !*is_recording.lock().unwrap() {
break; break;
@ -291,7 +291,7 @@ impl Emitter {
fn send(&mut self, markers: Vec<TimelineMarkerReply>) -> () { fn send(&mut self, markers: Vec<TimelineMarkerReply>) -> () {
let end_time = PreciseTime::now(); let end_time = PreciseTime::now();
let reply = MarkersEmitterReply { let reply = MarkersEmitterReply {
__type__: "markers".to_string(), __type__: "markers".to_owned(),
markers: markers, markers: markers,
from: self.from.clone(), from: self.from.clone(),
endTime: HighResolutionStamp::new(self.start_stamp, end_time), endTime: HighResolutionStamp::new(self.start_stamp, end_time),
@ -303,7 +303,7 @@ impl Emitter {
let registry = lock.as_mut().unwrap(); let registry = lock.as_mut().unwrap();
let framerate_actor = registry.find_mut::<FramerateActor>(actor_name); let framerate_actor = registry.find_mut::<FramerateActor>(actor_name);
let framerateReply = FramerateEmitterReply { let framerateReply = FramerateEmitterReply {
__type__: "framerate".to_string(), __type__: "framerate".to_owned(),
from: framerate_actor.name(), from: framerate_actor.name(),
delta: HighResolutionStamp::new(self.start_stamp, end_time), delta: HighResolutionStamp::new(self.start_stamp, end_time),
timestamps: framerate_actor.take_pending_ticks(), timestamps: framerate_actor.take_pending_ticks(),
@ -315,7 +315,7 @@ impl Emitter {
let registry = self.registry.lock().unwrap(); let registry = self.registry.lock().unwrap();
let memory_actor = registry.find::<MemoryActor>(actor_name); let memory_actor = registry.find::<MemoryActor>(actor_name);
let memoryReply = MemoryEmitterReply { let memoryReply = MemoryEmitterReply {
__type__: "memory".to_string(), __type__: "memory".to_owned(),
from: memory_actor.name(), from: memory_actor.name(),
delta: HighResolutionStamp::new(self.start_stamp, end_time), delta: HighResolutionStamp::new(self.start_stamp, end_time),
measurement: memory_actor.measure(), measurement: memory_actor.measure(),

View file

@ -276,7 +276,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
let console_actor = actors.find::<ConsoleActor>(&console_actor_name); let console_actor = actors.find::<ConsoleActor>(&console_actor_name);
let msg = ConsoleAPICall { let msg = ConsoleAPICall {
from: console_actor.name.clone(), from: console_actor.name.clone(),
__type__: "consoleAPICall".to_string(), __type__: "consoleAPICall".to_owned(),
message: ConsoleMsg { message: ConsoleMsg {
level: match console_message.logLevel { level: match console_message.logLevel {
LogLevel::Debug => "debug", LogLevel::Debug => "debug",
@ -284,7 +284,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
LogLevel::Warn => "warn", LogLevel::Warn => "warn",
LogLevel::Error => "error", LogLevel::Error => "error",
_ => "log" _ => "log"
}.to_string(), }.to_owned(),
timeStamp: precise_time_ns(), timeStamp: precise_time_ns(),
arguments: vec!(console_message.message), arguments: vec!(console_message.message),
filename: console_message.filename, filename: console_message.filename,
@ -344,7 +344,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
//Send a networkEvent message to the client //Send a networkEvent message to the client
let msg = NetworkEventMsg { let msg = NetworkEventMsg {
from: console_actor_name, from: console_actor_name,
__type__: "networkEvent".to_string(), __type__: "networkEvent".to_owned(),
eventActor: actor.event_actor(), eventActor: actor.event_actor(),
}; };
for stream in &mut connections { for stream in &mut connections {
@ -358,8 +358,8 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
//Send a networkEventUpdate (responseStart) to the client //Send a networkEventUpdate (responseStart) to the client
let msg = NetworkEventUpdateMsg { let msg = NetworkEventUpdateMsg {
from: netevent_actor_name, from: netevent_actor_name,
__type__: "networkEventUpdate".to_string(), __type__: "networkEventUpdate".to_owned(),
updateType: "responseStart".to_string(), updateType: "responseStart".to_owned(),
response: actor.response_start() response: actor.response_start()
}; };

View file

@ -35,17 +35,17 @@ impl JsonPacketStream for TcpStream {
Ok(0) => return Ok(None), // EOF Ok(0) => return Ok(None), // EOF
Ok(1) => buf[0], Ok(1) => buf[0],
Ok(_) => unreachable!(), Ok(_) => unreachable!(),
Err(e) => return Err(e.description().to_string()), Err(e) => return Err(e.description().to_owned()),
}; };
match byte { match byte {
b':' => { b':' => {
let packet_len_str = match String::from_utf8(buffer) { let packet_len_str = match String::from_utf8(buffer) {
Ok(packet_len) => packet_len, Ok(packet_len) => packet_len,
Err(_) => return Err("nonvalid UTF8 in packet length".to_string()), Err(_) => return Err("nonvalid UTF8 in packet length".to_owned()),
}; };
let packet_len = match u64::from_str_radix(&packet_len_str, 10) { let packet_len = match u64::from_str_radix(&packet_len_str, 10) {
Ok(packet_len) => packet_len, Ok(packet_len) => packet_len,
Err(_) => return Err("packet length missing / not parsable".to_string()), Err(_) => return Err("packet length missing / not parsable".to_owned()),
}; };
let mut packet = String::new(); let mut packet = String::new();
self.take(packet_len).read_to_string(&mut packet).unwrap(); self.take(packet_len).read_to_string(&mut packet).unwrap();
@ -53,7 +53,7 @@ impl JsonPacketStream for TcpStream {
return match Json::from_str(&packet) { return match Json::from_str(&packet) {
Ok(json) => Ok(Some(json)), Ok(json) => Ok(Some(json)),
Err(err) => match err { Err(err) => match err {
IoError(ioerr) => return Err(ioerr.description().to_string()), IoError(ioerr) => return Err(ioerr.description().to_owned()),
SyntaxError(_, l, c) => return Err(format!("syntax at {}:{}", l, c)), SyntaxError(_, l, c) => return Err(format!("syntax at {}:{}", l, c)),
}, },
}; };