Explorar o código

Rust updates (#3003)

* Update to Rust 1.21.0

* Update Iron dependencies

Updated serde uses serde_derive now instead of serde_codegen

* Update Nickel dependencies

Use serde for JSON serialization instead of rustc-serialize since the
latter is deprecated now.

* Update Rouille serde depencency

* Update tokio-minihttp depenencies

Align with Iron's postgres dependencies
Keith Gustafson %!s(int64=7) %!d(string=hai) anos
pai
achega
399ed1ba63

+ 8 - 11
frameworks/Rust/iron/Cargo.toml

@@ -1,18 +1,15 @@
 [package]
 name = "iron"
-version = "0.0.3"
-build = "build.rs"
-
-[build-dependencies]
-serde_codegen = "0.8"
+version = "0.0.4"
 
 [dependencies]
-serde = "0.8"
-serde_json = "0.8"
-iron = "0.4"
-router = "0.4"
-persistent = "0.2"
-hyper = "0.9"
+serde = "1.0"
+serde_json = "1.0"
+serde_derive = "1.0"
+iron = "0.5"
+router = "0.5"
+persistent = "0.3"
+hyper = "0.10"
 rand = "0.3"
 r2d2 = "0.7"
 postgres = "0.15.1"

+ 0 - 13
frameworks/Rust/iron/build.rs

@@ -1,13 +0,0 @@
-extern crate serde_codegen;
-
-use std::env;
-use std::path::Path;
-
-fn main() {
-    let out_dir = env::var_os("OUT_DIR").unwrap();
-
-    let src = Path::new("src/main_types.in.rs");
-    let dst = Path::new(&out_dir).join("main_types.rs");
-
-    serde_codegen::expand(&src, &dst).unwrap();
-}

+ 12 - 1
frameworks/Rust/iron/src/main.rs

@@ -3,6 +3,7 @@ extern crate persistent;
 #[macro_use] extern crate router;
 extern crate serde;
 extern crate serde_json;
+#[macro_use] extern crate serde_derive;
 extern crate hyper;
 extern crate rand;
 extern crate r2d2;
@@ -21,7 +22,17 @@ use r2d2_postgres::{PostgresConnectionManager, TlsMode};
 use persistent::{Read};
 use r2d2::Pool;
 
-include!(concat!(env!("OUT_DIR"),"/main_types.rs"));
+#[derive(Serialize, Deserialize)]
+struct Message {
+    message: String,
+}
+
+#[allow(non_snake_case)]
+#[derive(Serialize, Deserialize)]
+struct DatabaseRow {
+    id: i32,
+    randomNumber: i32
+}
 
 pub type PostgresPool = Pool<PostgresConnectionManager>;
 

+ 0 - 11
frameworks/Rust/iron/src/main_types.in.rs

@@ -1,11 +0,0 @@
-#[derive(Serialize, Deserialize)]
-struct Message {
-    message: String,
-}
-
-#[allow(non_snake_case)]
-#[derive(Serialize, Deserialize)]
-struct DatabaseRow {
-	id: i32,
-	randomNumber: i32
-}

+ 4 - 2
frameworks/Rust/nickel/Cargo.toml

@@ -1,9 +1,11 @@
 [package]
 
 name = "nickel"
-version = "0.0.1"
+version = "0.0.2"
 
 [dependencies]
-rustc-serialize = "0.3.19"
+serde = "1.0"
+serde_json = "1.0"
+serde_derive = "1.0"
 nickel = "0.10.0"
 nickel_macros = "0.1.0"

+ 6 - 5
frameworks/Rust/nickel/src/main.rs

@@ -1,11 +1,12 @@
 #[macro_use]
 extern crate nickel;
-extern crate rustc_serialize;
+extern crate serde;
+extern crate serde_json;
+#[macro_use] extern crate serde_derive;
 
 use nickel::{Nickel, HttpRouter, MediaType};
-use rustc_serialize::json;
 
-#[derive(RustcDecodable, RustcEncodable)]
+#[derive(Serialize, Deserialize)]
 struct Message {
     message: String,
 }
@@ -20,7 +21,7 @@ fn main() {
         let message: Message = Message{
             message: "Hello, World!".to_string(),
         };
-        json::encode(&message).unwrap()
+        serde_json::to_string(&message).unwrap()
     });
 
     router.get("/plaintext",
@@ -30,5 +31,5 @@ fn main() {
     });
 
     server.utilize(router);
-    server.listen("0.0.0.0:8080");
+    server.listen("0.0.0.0:8080").unwrap();
 }

+ 1 - 1
frameworks/Rust/rouille/Cargo.toml

@@ -5,4 +5,4 @@ authors = ["Gökberk Yaltıraklı <[email protected]>"]
 
 [dependencies]
 rouille = "1.0"
-serde_json = "0.9"
+serde_json = "1.0"

+ 11 - 10
frameworks/Rust/tokio-minihttp/Cargo.lock

@@ -6,9 +6,9 @@ dependencies = [
  "futures-cpupool 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "num_cpus 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "postgres 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "postgres 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "r2d2 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "r2d2_postgres 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "r2d2_postgres 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -299,14 +299,14 @@ dependencies = [
 
 [[package]]
 name = "postgres"
-version = "0.14.2"
+version = "0.15.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "bytes 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "fallible-iterator 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "postgres-protocol 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "postgres-shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "postgres-shared 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -329,7 +329,7 @@ dependencies = [
 
 [[package]]
 name = "postgres-shared"
-version = "0.3.0"
+version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "fallible-iterator 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -355,10 +355,11 @@ dependencies = [
 
 [[package]]
 name = "r2d2_postgres"
-version = "0.12.0"
+version = "0.13.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "postgres 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "postgres 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "postgres-shared 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "r2d2 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -660,12 +661,12 @@ dependencies = [
 "checksum percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de154f638187706bde41d9b4738748933d64e6b37bdbffc0b47a97d16a6ae356"
 "checksum phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "cb325642290f28ee14d8c6201159949a872f220c62af6e110a56ea914fbe42fc"
 "checksum phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "07e24b0ca9643bdecd0632f2b3da6b1b89bbb0030e0b992afc1113b23a7bc2f2"
-"checksum postgres 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b51f9f4b74a0d3a475fe272f5acc72761d750fd67af90cd2241bce49639ca395"
+"checksum postgres 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6e6dbad8297d43a1319817c45c43fd2cfd6a148767f51baedcdce732635c6526"
 "checksum postgres-protocol 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "685d511cb92a2b534de8e698ad0e72372032093809dd8bd138b171102a92fb5b"
-"checksum postgres-shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab14a2b628b6c36696d194e4b7c36187b505e2f51091191aeacfed89d6942d71"
+"checksum postgres-shared 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "22fcb88c55471615fea5217b41ab59df5a00665edb4e92f67c35119b7e8948ed"
 "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
 "checksum r2d2 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1dd448c29d0ed83cfe187ffb8608fa07c47abdd7997f3f478f3a6223ad3f97fb"
-"checksum r2d2_postgres 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00aae18ea6279c73dea01c5816fcd7ee1d0369e957f9445aebcbcb2927dd2b5c"
+"checksum r2d2_postgres 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1f8b19a6ea63676566dd11085217fed98866ca833cea7f6f29be8c2244e0560e"
 "checksum rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "022e0636ec2519ddae48154b028864bdce4eaf7d35226ab8e65c611be97b189d"
 "checksum redox_syscall 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "3041aeb6000db123d2c9c751433f526e1f404b23213bd733167ab770c3989b4d"
 "checksum scheduled-thread-pool 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d9fbe48ead32343b76f544c85953bf260ed39219a8bbbb62cd85f6a00f9644f"

+ 3 - 3
frameworks/Rust/tokio-minihttp/Cargo.toml

@@ -14,9 +14,9 @@ tokio-proto = "0.1"
 tokio-service = "0.1"
 tokio-minihttp = { git = "https://github.com/tokio-rs/tokio-minihttp" }
 
-postgres = "0.14"
+postgres = "0.15.1"
 r2d2 = "0.7"
 futures-cpupool = "0.1"
-r2d2_postgres = "0.12"
+r2d2_postgres = "0.13"
 rand = "0.3"
-url = "1.0"
+url = "1.5"

+ 1 - 1
toolset/setup/linux/languages/rust.sh

@@ -1,6 +1,6 @@
 #!/bin/bash
 
-RUST_VERSION="1.19.0"
+RUST_VERSION="1.21.0"
 
 fw_installed rust && return 0