Cleanup write_json_packet.

This commit is contained in:
Ms2ger 2015-09-02 19:49:06 +02:00
parent 366d4a83f1
commit 62a98e4918

View file

@ -22,9 +22,7 @@ impl JsonPacketStream for TcpStream {
fn write_json_packet<'a, T: Encodable>(&mut self, obj: &T) { fn write_json_packet<'a, T: Encodable>(&mut self, obj: &T) {
let s = json::encode(obj).unwrap().replace("__type__", "type"); let s = json::encode(obj).unwrap().replace("__type__", "type");
println!("<- {}", s); println!("<- {}", s);
self.write_all(s.len().to_string().as_bytes()).unwrap(); write!(self, "{}:{}", s.len(), s).unwrap();
self.write_all(&[':' as u8]).unwrap();
self.write_all(s.as_bytes()).unwrap();
} }
fn read_json_packet<'a>(&mut self) -> Result<Option<Json>, String> { fn read_json_packet<'a>(&mut self) -> Result<Option<Json>, String> {