about summary refs log tree commit diff
path: root/src/libserialize
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-12-18 22:52:48 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-12-22 00:14:56 -0800
commita76a80276852f05f30adaa4d2a8a2729b5fc0bfa (patch)
tree118a535c640013b22519f38dfa9af893dc5986a4 /src/libserialize
parent34d680009205de2302b902d8f9f5f7ae7a042f1a (diff)
downloadrust-a76a80276852f05f30adaa4d2a8a2729b5fc0bfa.tar.gz
rust-a76a80276852f05f30adaa4d2a8a2729b5fc0bfa.zip
serialize: Fully deprecate the library
This commit completes the deprecation story for the in-tree serialization
library. The compiler will now emit a warning whenever it encounters
`deriving(Encodable)` or `deriving(Decodable)`, and the library itself is now
marked `#[unstable]` for when feature staging is enabled.

All users of serialization can migrate to the `rustc-serialize` crate on
crates.io which provides the exact same interface as the libserialize library
in-tree. The new deriving modes are named `RustcEncodable` and `RustcDecodable`
and require `extern crate "rustc-serialize" as rustc_serialize` at the crate
root in order to expand correctly.

To migrate all crates, add the following to your `Cargo.toml`:

    [dependencies]
    rustc-serialize = "0.1.1"

And then add the following to your crate root:

    extern crate "rustc-serialize" as rustc_serialize;

Finally, rename `Encodable` and `Decodable` deriving modes to `RustcEncodable`
and `RustcDecodable`.

[breaking-change]
Diffstat (limited to 'src/libserialize')
-rw-r--r--src/libserialize/json.rs26
-rw-r--r--src/libserialize/lib.rs6
2 files changed, 18 insertions, 14 deletions
diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs
index 3181e28a121..15e7de08016 100644
--- a/src/libserialize/json.rs
+++ b/src/libserialize/json.rs
@@ -57,17 +57,17 @@
 //!
 //! Rust provides a mechanism for low boilerplate encoding & decoding of values to and from JSON via
 //! the serialization API.
-//! To be able to encode a piece of data, it must implement the `serialize::Encodable` trait.
-//! To be able to decode a piece of data, it must implement the `serialize::Decodable` trait.
+//! To be able to encode a piece of data, it must implement the `serialize::RustcEncodable` trait.
+//! To be able to decode a piece of data, it must implement the `serialize::RustcDecodable` trait.
 //! The Rust compiler provides an annotation to automatically generate the code for these traits:
-//! `#[deriving(Decodable, Encodable)]`
+//! `#[deriving(RustcDecodable, RustcEncodable)]`
 //!
 //! The JSON API provides an enum `json::Json` and a trait `ToJson` to encode objects.
 //! The `ToJson` trait provides a `to_json` method to convert an object into a `json::Json` value.
 //! A `json::Json` value can be encoded as a string or buffer using the functions described above.
 //! You can also use the `json::Encoder` object, which implements the `Encoder` trait.
 //!
-//! When using `ToJson` the `Encodable` trait implementation is not mandatory.
+//! When using `ToJson` the `RustcEncodable` trait implementation is not mandatory.
 //!
 //! # Examples of use
 //!
@@ -127,7 +127,7 @@
 //!     }
 //! }
 //!
-//! // Only generate `Encodable` trait implementation
+//! // Only generate `RustcEncodable` trait implementation
 //! #[deriving(Encodable)]
 //! pub struct ComplexNumRecord {
 //!     uid: u8,
@@ -404,7 +404,7 @@ impl<'a> Encoder<'a> {
     }
 
     /// Encode the specified struct into a json [u8]
-    pub fn buffer_encode<T:Encodable<Encoder<'a>, io::IoError>>(object: &T) -> Vec<u8>  {
+    pub fn buffer_encode<T: Encodable<Encoder<'a>, io::IoError>>(object: &T) -> Vec<u8>  {
         //Serialize the object in a string using a writer
         let mut m = Vec::new();
         // FIXME(14302) remove the transmute and unsafe block.
@@ -2428,7 +2428,7 @@ mod tests {
     use std::num::Float;
     use std::string;
 
-    #[deriving(Decodable, Eq, PartialEq, Show)]
+    #[deriving(RustcDecodable, Eq, PartialEq, Show)]
     struct OptionData {
         opt: Option<uint>,
     }
@@ -2455,20 +2455,20 @@ mod tests {
                                 ExpectedError("Number".into_string(), "false".into_string()));
     }
 
-    #[deriving(PartialEq, Encodable, Decodable, Show)]
+    #[deriving(PartialEq, RustcEncodable, RustcDecodable, Show)]
     enum Animal {
         Dog,
         Frog(string::String, int)
     }
 
-    #[deriving(PartialEq, Encodable, Decodable, Show)]
+    #[deriving(PartialEq, RustcEncodable, RustcDecodable, Show)]
     struct Inner {
         a: (),
         b: uint,
         c: Vec<string::String>,
     }
 
-    #[deriving(PartialEq, Encodable, Decodable, Show)]
+    #[deriving(PartialEq, RustcEncodable, RustcDecodable, Show)]
     struct Outer {
         inner: Vec<Inner>,
     }
@@ -3009,7 +3009,7 @@ mod tests {
         );
     }
 
-    #[deriving(Decodable)]
+    #[deriving(RustcDecodable)]
     struct FloatStruct {
         f: f64,
         a: Vec<f64>
@@ -3058,7 +3058,7 @@ mod tests {
             Err(SyntaxError(EOFWhileParsingObject, 3u, 8u)));
     }
 
-    #[deriving(Decodable)]
+    #[deriving(RustcDecodable)]
     #[allow(dead_code)]
     struct DecodeStruct {
         x: f64,
@@ -3066,7 +3066,7 @@ mod tests {
         z: string::String,
         w: Vec<DecodeStruct>
     }
-    #[deriving(Decodable)]
+    #[deriving(RustcDecodable)]
     enum DecodeEnum {
         A(f64),
         B(string::String)
diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs
index e700d102fef..7ed806fb3b6 100644
--- a/src/libserialize/lib.rs
+++ b/src/libserialize/lib.rs
@@ -15,7 +15,7 @@ Core encoding and decoding interfaces.
 */
 
 #![crate_name = "serialize"]
-#![experimental]
+#![unstable = "deprecated in favor of rustc-serialize on crates.io"]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
@@ -44,3 +44,7 @@ mod collection_impls;
 pub mod base64;
 pub mod hex;
 pub mod json;
+
+mod rustc_serialize {
+    pub use serialize::*;
+}