Upgrade dependencies to Serde 1.0.

Closes #272.
Resolves #273.
This commit is contained in:
Sergio Benitez 2017-04-24 17:37:18 -07:00
parent 40d11929d7
commit 30fac32978
10 changed files with 34 additions and 31 deletions

View File

@ -29,12 +29,12 @@ log = "^0.3"
uuid = { version = "^0.4", optional = true }
# Serialization and templating dependencies.
serde = { version = "^0.9", optional = true }
serde_json = { version = "^0.9.3", optional = true }
rmp-serde = { version = "^0.12", optional = true }
serde = { version = "1.0", optional = true }
serde_json = { version = "1.0", optional = true }
rmp-serde = { version = "^0.13", optional = true }
# Templating dependencies only.
handlebars = { version = "^0.25", optional = true, features = ["serde_type"] }
handlebars = { version = "^0.26.1", optional = true }
glob = { version = "^0.2", optional = true }
lazy_static = { version = "^0.2", optional = true }
tera = { version = "^0.8", optional = true }
tera = { version = "^0.10", optional = true }

View File

@ -8,7 +8,8 @@ use rocket::data::{self, Data, FromData};
use rocket::response::{self, Responder, content};
use rocket::http::Status;
use serde::{Serialize, Deserialize};
use serde::Serialize;
use serde::de::DeserializeOwned;
use serde_json;
@ -22,9 +23,9 @@ pub use serde_json::error::Error as SerdeError;
///
/// If you're receiving JSON data, simply add a `data` parameter to your route
/// arguments and ensure the type of the parameter is a `JSON<T>`, where `T` is
/// some type you'd like to parse from JSON. `T` must implement `Deserialize`
/// from [Serde](https://github.com/serde-rs/json). The data is parsed from the
/// HTTP request body.
/// some type you'd like to parse from JSON. `T` must implement `Deserialize` or
/// `DeserializeOwned` from [Serde](https://github.com/serde-rs/json). The data
/// is parsed from the HTTP request body.
///
/// ```rust,ignore
/// #[post("/users/", format = "application/json", data = "<user>")]
@ -87,7 +88,7 @@ impl<T> JSON<T> {
/// Default limit for JSON is 1MB.
const LIMIT: u64 = 1 << 20;
impl<T: Deserialize> FromData for JSON<T> {
impl<T: DeserializeOwned> FromData for JSON<T> {
type Error = SerdeError;
fn from_data(request: &Request, data: Data) -> data::Outcome<Self, SerdeError> {

View File

@ -10,7 +10,8 @@ use rocket::data::{self, Data, FromData};
use rocket::response::{self, Responder, Response};
use rocket::http::{ContentType, Status};
use serde::{Serialize, Deserialize};
use serde::Serialize;
use serde::de::DeserializeOwned;
pub use self::rmp_serde::decode::Error as MsgPackError;
@ -22,8 +23,9 @@ pub use self::rmp_serde::decode::Error as MsgPackError;
/// If you're receiving MessagePack data, simply add a `data` parameter to your
/// route arguments and ensure the type of the parameter is a `MsgPack<T>`,
/// where `T` is some type you'd like to parse from MessagePack. `T` must
/// implement `Deserialize` from [Serde](https://github.com/serde-rs/serde). The
/// data is parsed from the HTTP request body.
/// implement `Deserialize` or `DeserializeOwned` from
/// [Serde](https://github.com/serde-rs/serde). The data is parsed from the HTTP
/// request body.
///
/// ```rust,ignore
/// #[post("/users/", format = "application/msgpack", data = "<user>")]
@ -100,7 +102,7 @@ fn is_msgpack_content_type(ct: &ContentType) -> bool {
&& (ct.sub() == "msgpack" || ct.sub() == "x-msgpack")
}
impl<T: Deserialize> FromData for MsgPack<T> {
impl<T: DeserializeOwned> FromData for MsgPack<T> {
type Error = MsgPackError;
fn from_data(request: &Request, data: Data) -> data::Outcome<Self, Self::Error> {

View File

@ -6,6 +6,6 @@ workspace = "../../"
[dependencies]
rocket = { path = "../../lib" }
rocket_codegen = { path = "../../codegen" }
serde = "0.9"
serde_json = "0.9"
serde_derive = "0.9"
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"

View File

@ -6,9 +6,9 @@ workspace = "../../"
[dependencies]
rocket = { path = "../../lib" }
rocket_codegen = { path = "../../codegen" }
serde = "0.9"
serde_derive = "0.9"
serde_json = "0.9"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
[dependencies.rocket_contrib]
path = "../../contrib"

View File

@ -6,9 +6,9 @@ workspace = "../../"
[dependencies]
rocket = { path = "../../lib" }
rocket_codegen = { path = "../../codegen" }
serde = "0.9"
serde_json = "0.9"
serde_derive = "0.9"
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
[dependencies.rocket_contrib]
path = "../../contrib"

View File

@ -6,8 +6,8 @@ workspace = "../../"
[dependencies]
rocket = { path = "../../lib" }
rocket_codegen = { path = "../../codegen" }
serde = "0.9"
serde_derive = "0.9"
serde = "1.0"
serde_derive = "1.0"
[dependencies.rocket_contrib]
path = "../../contrib"

View File

@ -6,9 +6,9 @@ workspace = "../../"
[dependencies]
rocket = { path = "../../lib" }
rocket_codegen = { path = "../../codegen" }
serde = "0.9"
serde_json = "0.9"
serde_derive = "0.9"
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
r2d2 = "0.7"
diesel = { version = "0.12", features = ["sqlite"] }
diesel_codegen = { version = "0.12", features = ["sqlite"] }

View File

@ -1,4 +1,4 @@
use std::io::{self, Read, Write, Cursor, BufReader, Chain, Take};
use std::io::{self, Read, Write, Cursor, Chain};
use std::path::Path;
use std::fs::File;
use std::time::Duration;
@ -205,7 +205,7 @@ impl Data {
}
/// This creates a `data` object from a local data source `data`.
pub(crate) fn local(mut data: Vec<u8>) -> Data {
pub(crate) fn local(data: Vec<u8>) -> Data {
let empty_stream = Cursor::new(vec![])
.chain(NetStream::Local(Cursor::new(vec![])));

View File

@ -1,4 +1,4 @@
use std::io::{self, BufRead, Read, Cursor, BufReader, Chain};
use std::io::{self, Read, Cursor, Chain};
use super::data::BodyReader;