From c688836a16e276964f258d0031a987ff7600b7b0 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sun, 30 Sep 2018 18:14:36 -0700 Subject: [PATCH] Use hex module for hex decoding, removing deprecated rustc-serialize for https://github.com/iceiix/steven/issues/4 --- Cargo.lock | 8 +++++++- Cargo.toml | 2 +- src/main.rs | 2 +- src/protocol/mod.rs | 12 ++++++------ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02e71e9..272e88b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -213,6 +213,11 @@ dependencies = [ "xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "hpack" version = "0.2.0" @@ -771,13 +776,13 @@ dependencies = [ "cgmath 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "collision 0.5.1 (git+https://github.com/TheUnnamedDude/collision-rs?rev=f80825e)", "flate2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "sdl2 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1032,6 +1037,7 @@ dependencies = [ "checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518" "checksum gif 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff3414b424657317e708489d2857d9575f4403698428b040b609b9d1c1a84a2c" "checksum gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a795170cbd85b5a7baa58d6d7525cae6a03e486859860c220f7ebbbdd379d0a" +"checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" "checksum hpack 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d2da7d3a34cf6406d9d700111b8eafafe9a251de41ae71d8052748259343b58" "checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" "checksum hyper 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bb0f4d00bb781e559b6e66ae4b5479df0fdf9ab15949f52fa2f1f5de16d4cc07" diff --git a/Cargo.toml b/Cargo.toml index 2cda4d6..d4283c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ flate2 = "1.0.2" zip = "0.4.2" image = "0.20.0" rand = "0.3.14" -rustc-serialize = "0.3.24" +hex = "0.3.2" base64 = "0.9.3" log = "0.4.5" cgmath = "0.7.0" diff --git a/src/main.rs b/src/main.rs index 8512f69..b038860 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,7 +26,7 @@ extern crate sha1; extern crate hyper; extern crate flate2; extern crate rand; -extern crate rustc_serialize; +extern crate hex; extern crate base64; extern crate cgmath; #[macro_use] diff --git a/src/protocol/mod.rs b/src/protocol/mod.rs index 2ae6e3f..6625da4 100644 --- a/src/protocol/mod.rs +++ b/src/protocol/mod.rs @@ -350,16 +350,16 @@ pub struct UUID(u64, u64); impl UUID { pub fn from_str(s: &str) -> UUID { - use rustc_serialize::hex::FromHex; + use hex; // TODO: Panics aren't the best idea here if s.len() != 36 { panic!("Invalid UUID format"); } - let mut parts = s[..8].from_hex().unwrap(); - parts.extend_from_slice(&s[9..13].from_hex().unwrap()); - parts.extend_from_slice(&s[14..18].from_hex().unwrap()); - parts.extend_from_slice(&s[19..23].from_hex().unwrap()); - parts.extend_from_slice(&s[24..36].from_hex().unwrap()); + let mut parts = hex::decode(&s[..8]).unwrap(); + parts.extend_from_slice(&hex::decode(&s[9..13]).unwrap()); + parts.extend_from_slice(&hex::decode(&s[14..18]).unwrap()); + parts.extend_from_slice(&hex::decode(&s[19..23]).unwrap()); + parts.extend_from_slice(&hex::decode(&s[24..36]).unwrap()); let mut high = 0u64; let mut low = 0u64; for i in 0 .. 8 {