Skip to content

Commit

Permalink
removed rust serialize (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashfordneil authored and Michael Eden committed May 15, 2017
1 parent a27bca8 commit fbdbc62
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ license = "MIT"
hyper = "^0.10.6"
unicase = "^1.0"
url = "^1.0"
rustc-serialize = "^0.3"
bitflags = "^0.8"
rand = "^0.3"
byteorder = "^1.0"
sha1 = "^0.2"
openssl = { version = "^0.9.10", optional = true }
base64 = "^0.5"

[dev-dependencies]
serde_json = "^1.0"

[features]
default = ["ssl"]
Expand Down
5 changes: 2 additions & 3 deletions examples/autobahn-client.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
extern crate websocket;
extern crate rustc_serialize as serialize;
extern crate serde_json;

use std::str::from_utf8;
use websocket::ClientBuilder;
use websocket::Message;
use websocket::message::Type;
use serialize::json;

fn main() {
let addr = "ws://127.0.0.1:9001".to_string();
Expand Down Expand Up @@ -93,7 +92,7 @@ fn get_case_count(addr: String) -> usize {
};
match message.opcode {
Type::Text => {
count = json::decode(from_utf8(&*message.payload).unwrap()).unwrap();
count = serde_json::from_str(from_utf8(&*message.payload).unwrap()).unwrap();
println!("Will run {} cases...", count);
}
Type::Close => {
Expand Down
6 changes: 3 additions & 3 deletions src/header/accept.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use base64;
use hyper::header::{Header, HeaderFormat};
use hyper::header::parsing::from_one_raw_str;
use hyper;
use std::fmt::{self, Debug};
use std::str::FromStr;
use serialize::base64::{ToBase64, FromBase64, STANDARD};
use header::WebSocketKey;
use result::{WebSocketResult, WebSocketError};
use sha1::Sha1;
Expand All @@ -24,7 +24,7 @@ impl FromStr for WebSocketAccept {
type Err = WebSocketError;

fn from_str(accept: &str) -> WebSocketResult<WebSocketAccept> {
match accept.from_base64() {
match base64::decode(accept) {
Ok(vec) => {
if vec.len() != 20 {
return Err(WebSocketError::ProtocolError("Sec-WebSocket-Accept must be 20 bytes"));
Expand Down Expand Up @@ -56,7 +56,7 @@ impl WebSocketAccept {
/// Return the Base64 encoding of this WebSocketAccept
pub fn serialize(&self) -> String {
let WebSocketAccept(accept) = *self;
accept.to_base64(STANDARD)
base64::encode(&accept)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/header/key.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use base64;
use hyper::header::{Header, HeaderFormat};
use hyper::header::parsing::from_one_raw_str;
use hyper;
use std::fmt::{self, Debug};
use rand;
use std::mem;
use std::str::FromStr;
use serialize::base64::{ToBase64, FromBase64, STANDARD};
use result::{WebSocketResult, WebSocketError};

/// Represents a Sec-WebSocket-Key header.
Expand All @@ -22,7 +22,7 @@ impl FromStr for WebSocketKey {
type Err = WebSocketError;

fn from_str(key: &str) -> WebSocketResult<WebSocketKey> {
match key.from_base64() {
match base64::decode(key) {
Ok(vec) => {
if vec.len() != 16 {
return Err(WebSocketError::ProtocolError("Sec-WebSocket-Key must be 16 bytes"));
Expand Down Expand Up @@ -52,7 +52,7 @@ impl WebSocketKey {
/// Return the Base64 encoding of this WebSocketKey
pub fn serialize(&self) -> String {
let WebSocketKey(key) = *self;
key.to_base64(STANDARD)
base64::encode(&key)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
extern crate hyper;
extern crate unicase;
pub extern crate url;
extern crate rustc_serialize as serialize;
extern crate rand;
extern crate byteorder;
extern crate sha1;
#[cfg(feature="ssl")]
extern crate openssl;
extern crate base64;

#[macro_use]
extern crate bitflags;
Expand Down

0 comments on commit fbdbc62

Please sign in to comment.