From e89687e712f201346f691cb7901f93c18d12e74f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Fro=C5=82ow?= Date: Sun, 12 Jan 2020 14:04:02 +0100 Subject: [PATCH] Remove serde_derive https://github.com/serde-rs/serde/issues/1441#issuecomment-445481084 --- async_db/Cargo.toml | 3 +-- async_db/README.md | 7 +++++++ async_db/src/db.rs | 2 +- async_ex1/Cargo.toml | 3 +-- async_ex1/src/main.rs | 3 +-- diesel/Cargo.toml | 3 +-- diesel/src/main.rs | 3 +-- diesel/src/models.rs | 1 + form/Cargo.toml | 3 +-- form/src/main.rs | 3 +-- json/Cargo.toml | 3 +-- json/src/main.rs | 2 +- jsonrpc/Cargo.toml | 3 +-- jsonrpc/src/convention.rs | 2 +- redis/Cargo.toml | 3 +-- redis/src/main.rs | 3 +-- todo/Cargo.toml | 3 +-- todo/src/api.rs | 1 + todo/src/main.rs | 2 -- todo/src/model.rs | 1 + todo/src/session.rs | 1 + web-cors/backend/Cargo.toml | 3 +-- web-cors/backend/src/main.rs | 3 --- web-cors/backend/src/user.rs | 1 + websocket-tcp-chat/Cargo.toml | 5 ++--- websocket-tcp-chat/src/client.rs | 3 --- websocket-tcp-chat/src/codec.rs | 1 + websocket-tcp-chat/src/main.rs | 3 +-- 28 files changed, 32 insertions(+), 42 deletions(-) diff --git a/async_db/Cargo.toml b/async_db/Cargo.toml index 6b3d2601..e6ec7969 100644 --- a/async_db/Cargo.toml +++ b/async_db/Cargo.toml @@ -17,6 +17,5 @@ num_cpus = "1.10.0" r2d2 = "0.8.2" r2d2_sqlite = "0.8.0" rusqlite = "0.16" -serde = "1.0" +serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -serde_derive = "1.0" diff --git a/async_db/README.md b/async_db/README.md index 1d8bd22f..0cfe28a7 100644 --- a/async_db/README.md +++ b/async_db/README.md @@ -38,3 +38,10 @@ sqlite> .tables sqlite> select * from nyc_weather; ``` +## Dependencies + +On Ubuntu 19.10: + +``` +sudo apt install libsqlite3-dev +``` diff --git a/async_db/src/db.rs b/async_db/src/db.rs index 7d3f6346..65329601 100644 --- a/async_db/src/db.rs +++ b/async_db/src/db.rs @@ -4,7 +4,7 @@ use futures::{Future, TryFutureExt}; use r2d2; use r2d2_sqlite; use rusqlite::NO_PARAMS; -use serde_derive::{Deserialize, Serialize}; +use serde::{Deserialize, Serialize}; use std::{thread::sleep, time::Duration}; pub type Pool = r2d2::Pool; diff --git a/async_ex1/Cargo.toml b/async_ex1/Cargo.toml index c5329786..5e2c2aaa 100644 --- a/async_ex1/Cargo.toml +++ b/async_ex1/Cargo.toml @@ -10,8 +10,7 @@ actix-rt = "1.0.0" actix-web = { version="2.0.0", features=["openssl"] } futures = "0.3.1" -serde = "1.0.43" -serde_derive = "1.0.43" +serde = { version = "1.0.43", features = ["derive"] } serde_json = "1.0.16" validator = "0.6.3" validator_derive = "0.6.5" diff --git a/async_ex1/src/main.rs b/async_ex1/src/main.rs index dc9e25d1..f78744c7 100644 --- a/async_ex1/src/main.rs +++ b/async_ex1/src/main.rs @@ -14,8 +14,7 @@ #[macro_use] extern crate validator_derive; -#[macro_use] -extern crate serde_derive; +use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::io; diff --git a/diesel/Cargo.toml b/diesel/Cargo.toml index e3f28b33..78cf2c45 100644 --- a/diesel/Cargo.toml +++ b/diesel/Cargo.toml @@ -13,9 +13,8 @@ bytes = "0.4" env_logger = "0.6" futures = "0.3.1" uuid = { version = "0.5", features = ["serde", "v4"] } -serde = "1.0" +serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -serde_derive = "1.0" diesel = { version = "^1.1.0", features = ["sqlite", "r2d2"] } r2d2 = "0.8" diff --git a/diesel/src/main.rs b/diesel/src/main.rs index 053d7e37..f5d019e6 100644 --- a/diesel/src/main.rs +++ b/diesel/src/main.rs @@ -6,8 +6,7 @@ //! of them can run in parallel and process messages from same queue. #[macro_use] extern crate diesel; -#[macro_use] -extern crate serde_derive; +use serde::{Deserialize, Serialize}; use actix_web::{error, middleware, web, App, Error, HttpResponse, HttpServer}; use diesel::prelude::*; diff --git a/diesel/src/models.rs b/diesel/src/models.rs index 315d59f1..9d8c816e 100644 --- a/diesel/src/models.rs +++ b/diesel/src/models.rs @@ -1,4 +1,5 @@ use super::schema::users; +use serde::Serialize; #[derive(Serialize, Queryable)] pub struct User { diff --git a/form/Cargo.toml b/form/Cargo.toml index 0c1a0cec..d3aa62c4 100644 --- a/form/Cargo.toml +++ b/form/Cargo.toml @@ -8,5 +8,4 @@ workspace = ".." [dependencies] actix-web = "2.0.0" actix-rt = "1.0.0" -serde = "1.0" -serde_derive = "1.0" +serde = { version = "1.0", features = ["derive"] } diff --git a/form/src/main.rs b/form/src/main.rs index c429332a..27635ed3 100644 --- a/form/src/main.rs +++ b/form/src/main.rs @@ -1,5 +1,4 @@ -#[macro_use] -extern crate serde_derive; +use serde::{Deserialize, Serialize}; use actix_web::{ middleware, web, App, HttpRequest, HttpResponse, HttpServer, Responder, Result, diff --git a/json/Cargo.toml b/json/Cargo.toml index 9c75d1f3..d60ba584 100644 --- a/json/Cargo.toml +++ b/json/Cargo.toml @@ -14,7 +14,6 @@ bytes = "0.5.2" futures = "0.3.1" env_logger = "*" -serde = "1.0" +serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -serde_derive = "1.0" json = "*" diff --git a/json/src/main.rs b/json/src/main.rs index c61640a9..8537b07d 100644 --- a/json/src/main.rs +++ b/json/src/main.rs @@ -4,7 +4,7 @@ use actix_web::{ use bytes::{Bytes, BytesMut}; use futures::StreamExt; use json::JsonValue; -use serde_derive::{Deserialize, Serialize}; +use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] struct MyObj { diff --git a/jsonrpc/Cargo.toml b/jsonrpc/Cargo.toml index 50e6f707..db2d8c5c 100644 --- a/jsonrpc/Cargo.toml +++ b/jsonrpc/Cargo.toml @@ -12,6 +12,5 @@ bytes = "0.5" env_logger = "0.6" futures = "0.3.1" log = "0.4" -serde = "1.0" -serde_derive = "1.0" +serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/jsonrpc/src/convention.rs b/jsonrpc/src/convention.rs index 300b826d..e3aca499 100644 --- a/jsonrpc/src/convention.rs +++ b/jsonrpc/src/convention.rs @@ -3,7 +3,7 @@ use std::error; use std::fmt; -use serde_derive::{Deserialize, Serialize}; +use serde::{Deserialize, Serialize}; use serde_json::Value; pub static JSONRPC_VERSION: &str = "2.0"; diff --git a/redis/Cargo.toml b/redis/Cargo.toml index 7c56038c..ec3d8cae 100644 --- a/redis/Cargo.toml +++ b/redis/Cargo.toml @@ -11,6 +11,5 @@ actix-web = "2.0.0" actix-redis = "0.8.0" futures = "0.3.1" redis-async = "0.6.1" -serde = "1.0.71" -serde_derive = "1.0.71" +serde = { version = "1.0.71", features = ["derive"] } env_logger = "0.6" diff --git a/redis/src/main.rs b/redis/src/main.rs index 49134780..268facea 100644 --- a/redis/src/main.rs +++ b/redis/src/main.rs @@ -1,7 +1,6 @@ #[macro_use] extern crate redis_async; -#[macro_use] -extern crate serde_derive; +use serde::Deserialize; use actix::prelude::*; use actix_redis::{Command, RedisActor}; diff --git a/todo/Cargo.toml b/todo/Cargo.toml index e8084f0e..4f39811e 100644 --- a/todo/Cargo.toml +++ b/todo/Cargo.toml @@ -13,8 +13,7 @@ dotenv = "0.13.0" env_logger = "0.5.10" futures = "0.3.1" log = "0.4.3" -serde = "1.0.69" -serde_derive = "1.0.69" +serde = { version = "1.0.69", features = ["derive"] } serde_json = "1.0.22" tera = "1.0" diff --git a/todo/src/api.rs b/todo/src/api.rs index dd1d826b..344fbb43 100644 --- a/todo/src/api.rs +++ b/todo/src/api.rs @@ -2,6 +2,7 @@ use actix_files::NamedFile; use actix_session::Session; use actix_web::middleware::errhandlers::ErrorHandlerResponse; use actix_web::{dev, error, http, web, Error, HttpResponse, Result}; +use serde::Deserialize; use tera::{Context, Tera}; use crate::db; diff --git a/todo/src/main.rs b/todo/src/main.rs index d464ad0c..54ce36fb 100644 --- a/todo/src/main.rs +++ b/todo/src/main.rs @@ -2,8 +2,6 @@ extern crate diesel; #[macro_use] extern crate log; -#[macro_use] -extern crate serde_derive; use std::{env, io}; diff --git a/todo/src/model.rs b/todo/src/model.rs index 4b80f4a8..2c8c03a6 100644 --- a/todo/src/model.rs +++ b/todo/src/model.rs @@ -1,6 +1,7 @@ use diesel; use diesel::pg::PgConnection; use diesel::prelude::*; +use serde::Serialize; use crate::schema::{ tasks, diff --git a/todo/src/session.rs b/todo/src/session.rs index d1cfc7a4..abeb500a 100644 --- a/todo/src/session.rs +++ b/todo/src/session.rs @@ -1,5 +1,6 @@ use actix_session::Session; use actix_web::error::Result; +use serde::{Deserialize, Serialize}; const FLASH_KEY: &str = "flash"; diff --git a/web-cors/backend/Cargo.toml b/web-cors/backend/Cargo.toml index 703f50b5..52dfd4fb 100644 --- a/web-cors/backend/Cargo.toml +++ b/web-cors/backend/Cargo.toml @@ -8,8 +8,7 @@ edition = "2018" actix-rt = "1.0.0" actix-web = "2.0.0" actix-cors = "0.2.0" -serde = "1.0" -serde_derive = "1.0" +serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" dotenv = "0.10" env_logger = "0.6" diff --git a/web-cors/backend/src/main.rs b/web-cors/backend/src/main.rs index 55e2d7ca..23fb8d87 100644 --- a/web-cors/backend/src/main.rs +++ b/web-cors/backend/src/main.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate serde_derive; - use actix_cors::Cors; use actix_web::{http::header, middleware::Logger, web, App, HttpServer}; diff --git a/web-cors/backend/src/user.rs b/web-cors/backend/src/user.rs index ee7dd783..09239c16 100644 --- a/web-cors/backend/src/user.rs +++ b/web-cors/backend/src/user.rs @@ -1,4 +1,5 @@ use actix_web::web; +use serde::{Deserialize, Serialize}; #[derive(Deserialize, Serialize, Debug)] pub struct Info { diff --git a/websocket-tcp-chat/Cargo.toml b/websocket-tcp-chat/Cargo.toml index 0b566c6c..8e3466d9 100644 --- a/websocket-tcp-chat/Cargo.toml +++ b/websocket-tcp-chat/Cargo.toml @@ -25,8 +25,7 @@ bytes = "0.5.3" byteorder = "1.2" futures = "0.3" env_logger = "0.6" -serde = "1.0" +serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -serde_derive = "1.0" tokio = "0.2.4" -tokio-util = "0.2.0" \ No newline at end of file +tokio-util = "0.2.0" diff --git a/websocket-tcp-chat/src/client.rs b/websocket-tcp-chat/src/client.rs index 61edaca1..df26b160 100644 --- a/websocket-tcp-chat/src/client.rs +++ b/websocket-tcp-chat/src/client.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate serde_derive; - use actix::prelude::*; use std::str::FromStr; use std::time::Duration; diff --git a/websocket-tcp-chat/src/codec.rs b/websocket-tcp-chat/src/codec.rs index 505ea6f1..56f4717e 100644 --- a/websocket-tcp-chat/src/codec.rs +++ b/websocket-tcp-chat/src/codec.rs @@ -5,6 +5,7 @@ use actix::prelude::*; use actix_codec::{Decoder, Encoder}; use byteorder::{BigEndian, ByteOrder}; use bytes::{BufMut, BytesMut}; +use serde::{Deserialize, Serialize}; use serde_json as json; /// Client request diff --git a/websocket-tcp-chat/src/main.rs b/websocket-tcp-chat/src/main.rs index 348d11ed..b6952ae0 100644 --- a/websocket-tcp-chat/src/main.rs +++ b/websocket-tcp-chat/src/main.rs @@ -1,5 +1,4 @@ -#[macro_use] -extern crate serde_derive; +use serde::{Deserialize, Serialize}; use std::time::{Duration, Instant};