diff --git a/src/mako/Cargo.toml.mako b/src/mako/Cargo.toml.mako index c55f94f33a2..c32f9cf4095 100644 --- a/src/mako/Cargo.toml.mako +++ b/src/mako/Cargo.toml.mako @@ -19,5 +19,6 @@ keywords = ["${name}", ${", ".join(estr(cargo.keywords))}] hyper = "*" mime = "*" url = "*" -rustc-serialize = "*" +serde = "*" +serde_macros = "*" yup-oauth2 = "*" diff --git a/src/mako/lib.rs.mako b/src/mako/lib.rs.mako index 3005da61698..b951bb25076 100644 --- a/src/mako/lib.rs.mako +++ b/src/mako/lib.rs.mako @@ -28,10 +28,12 @@ ${lib.docs(c)} // Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any // unused imports in fully featured APIs. Same with unused_mut ... . #![allow(unused_imports, unused_mut)] - +// Required for serde annotations +#![feature(custom_derive, plugin)] +#![plugin(serde_macros)] extern crate hyper; -extern crate "rustc-serialize" as rustc_serialize; +extern crate serde; extern crate "yup-oauth2" as oauth2; extern crate mime; extern crate url; @@ -44,7 +46,7 @@ use std::borrow::BorrowMut; use std::default::Default; use std::collections::BTreeMap; use std::marker::PhantomData; -use rustc_serialize::json; +use serde::json; use std::io; use std::fs; use std::old_io::timer::sleep; diff --git a/src/mako/lib/mbuild.mako b/src/mako/lib/mbuild.mako index b738f010baa..929dd7a286e 100644 --- a/src/mako/lib/mbuild.mako +++ b/src/mako/lib/mbuild.mako @@ -649,7 +649,7 @@ else { % if request_value: let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::encode(&self.${property(REQUEST_VALUE_PROPERTY_NAME)}).unwrap().into_bytes()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self.${property(REQUEST_VALUE_PROPERTY_NAME)}).unwrap()); let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); % endif @@ -727,7 +727,7 @@ else { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); - let error_info: cmn::JsonServerError = json::decode(&json_err).unwrap(); + let error_info: cmn::JsonServerError = json::from_str(&json_err).unwrap(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, error_info) { sleep(d); continue; @@ -744,7 +744,7 @@ if enable_resource_parsing \ { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); - (res, json::decode(&json_response).unwrap()) + (res, json::from_str(&json_response).unwrap()) }\ % if supports_download: else { (res, Default::default()) }\ diff --git a/src/mako/lib/schema.mako b/src/mako/lib/schema.mako index b12593903cc..d7c669dc5ea 100644 --- a/src/mako/lib/schema.mako +++ b/src/mako/lib/schema.mako @@ -34,9 +34,9 @@ ${struct}; traits = ['Default', 'Clone', 'Debug'] if REQUEST_MARKER_TRAIT in markers: - traits.append('RustcEncodable') + traits.append('Serialize') if RESPONSE_MARKER_TRAIT in markers: - traits.append('RustcDecodable') + traits.append('Deserialize') ## waiting for Default: https://github.com/rust-lang/rustc-serialize/issues/71 if s.type == 'any': @@ -58,11 +58,11 @@ ${_new_object(s, s.items.get('properties'), c)}\ % endif ## array item != 'object' % elif s.type == 'any': ## waiting for Default: https://github.com/rust-lang/rustc-serialize/issues/71 -pub struct ${s_type}(rustc_serialize::json::Json); +pub struct ${s_type}(json::Value); impl Default for ${s_type} { fn default() -> ${s_type} { - ${s_type}(rustc_serialize::json::Json::Null) + ${s_type}(json::Value::Null) } } % else: diff --git a/src/mako/lib/util.mako b/src/mako/lib/util.mako index 3e71820ad84..464c8da0e92 100644 --- a/src/mako/lib/util.mako +++ b/src/mako/lib/util.mako @@ -32,7 +32,7 @@ ${util.library_to_crate_name(util.library_name(name, version))}\ <%def name="test_prelude()">\ extern crate hyper; extern crate "yup-oauth2" as oauth2; -extern crate "rustc-serialize" as rustc_serialize; +extern crate serde; extern crate "${self.crate_name()}" as ${self.library_name()}; diff --git a/src/rust/cmn.rs b/src/rust/cmn.rs index 159eef72ca9..45b31cf1925 100644 --- a/src/rust/cmn.rs +++ b/src/rust/cmn.rs @@ -43,7 +43,7 @@ impl ReadSeek for T {} /// A utility type which can decode a server response that indicates error -#[derive(RustcDecodable)] +#[derive(Deserialize)] pub struct JsonServerError { error: String, error_description: Option diff --git a/src/rust/lib.rs b/src/rust/lib.rs index 17d7197c52b..12fff2ad324 100644 --- a/src/rust/lib.rs +++ b/src/rust/lib.rs @@ -1,10 +1,11 @@ -#![feature(core,io,old_path)] +#![feature(core,io,old_path, custom_derive, plugin)] #![allow(dead_code, deprecated, unused_features)] //! library with code shared by all generated implementations +#![plugin(serde_macros)] extern crate hyper; extern crate mime; -extern crate "rustc-serialize" as rustc_serialize; extern crate "yup-oauth2" as oauth2; +extern crate serde; // just pull it in the check if it compiles mod cmn;