Timespec in a RustcEncodable/Decodable Struct


I have a struct that I am applying the RustcEncodable and RustcDecodable attributes to. The struct contains a Timespec and the compiler is complaining that Timespec is missing the functions it needs to encode and decode itself. I find this odd as the code for Timespec has #[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))] and I do have rustc-serialize as a dependency in my Cargo.toml.

Is there something else that has to be done to have to compiler add the necessary functions to the Timespec structure?


You need to activate the rustc-serialize feature in the crate where Timespec comes from. Features are only local to the crates, themselves.


How do I activate it? Do I need to make a fork of the crate with a modified Cargo.toml?


No, just change your dependency entry like this:

version = "..."
features = ["rustc-serialize"]

You can read more about it here.