Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between the "serialize" and "rustc-serialize" crates?

Tags:

rust

This is the serialize crate, and this is the rustc-serialize crate.

I'm getting deprecation warnings from the compiler when using the Encodable and Decodable traits from the serialize crate. The compiler tells me to use RustcEncodable and RustcDecodable from the rustc-serialize crate.

It seems like this just makes things less readable for the same functionality (apart from base64 encoding provided in rustc-serialize). What's the difference between these crates?

like image 679
conradkleinespel Avatar asked Feb 11 '15 14:02

conradkleinespel


1 Answers

The serialize crate is an internal part of the standard Rust distribution. It won't be available in the Rust 1.0 stable/beta channels.

The rustc-serialize crate used to be serialize, but it was moved out to a separate repository and uploaded to crates.io so that it can evolve on its own.

This was done because the utility of rustc-serialize is enormous but it was not realistic to get it stabilized in time for Rust 1.0. Since the Rust distribution will prohibit unstable features on the stable channel, the only way to continue using the serialization infrastructure is to 1) stabilize what we have or 2) move it to crates.io, where the unstable restrictions don't apply.

rustc-serialize has a lot of known downsides, and it is being worked on, so stabilizing what was there really isn't an option.

But the Decodable/Encodable features require compiler support (because compiler plugins won't be stable either for Rust 1.0). As a stopgap measure, RustcDecodable/RustcEncodable were invented as a temporary measure for the rustc-serialize crate to use explicitly. It's a bit weird, but it leaves the Decodable/Encodable names available for a future backwards-compatible version of a serialize crate that is better than what we have now (perhaps this is what serde2 will become from the aforementioned link).

So for the time being, stick to use rustc-serialize and RustcDecodable/RustcEncodable.

(I apologize that I can't come up with a link to cite all of this. It's knowledge I've accrued over time from GitHub issues. Maybe there is an RFC that lays all of this out though. I can't remember.)

like image 119
BurntSushi5 Avatar answered Nov 20 '22 21:11

BurntSushi5