diff --git a/Cargo.toml b/Cargo.toml index c06410a..44a4fcc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,3 +11,5 @@ rustc-serialize = "0.3.2" rand = "0.3.7" num = "0.1.24" log = "0.3.1" +serde = "*" +serde_macros = "*" diff --git a/src/lib.rs b/src/lib.rs index e4e6e19..ff5e864 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,11 +7,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(asm, simd, zero_one, test)] +#![feature(asm, custom_derive, plugin, simd, zero_one, test)] + +#![plugin(serde_macros)] #[macro_use] extern crate log; extern crate rustc_serialize; +extern crate serde; extern crate rand; extern crate test; diff --git a/src/matrix.rs b/src/matrix.rs index 800a596..d636e57 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -11,7 +11,7 @@ use approxeq::ApproxEq; use point::{Point2D, Point4D}; -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, PartialEq, Deserialize, Serialize)] pub struct Matrix4 { pub m11: f32, pub m12: f32, pub m13: f32, pub m14: f32, pub m21: f32, pub m22: f32, pub m23: f32, pub m24: f32, diff --git a/src/point.rs b/src/point.rs index 465b7ce..903d028 100644 --- a/src/point.rs +++ b/src/point.rs @@ -15,7 +15,7 @@ use num_lib::NumCast; use std::fmt::{self, Formatter}; use std::ops::{Add, Neg, Mul, Sub, Div}; -#[derive(Clone, Copy, RustcDecodable, RustcEncodable, Eq, Hash, PartialEq)] +#[derive(Clone, Copy, RustcDecodable, RustcEncodable, Eq, Hash, PartialEq, Deserialize, Serialize)] pub struct Point2D { pub x: T, pub y: T diff --git a/src/rect.rs b/src/rect.rs index 4ad3ec4..51bd672 100644 --- a/src/rect.rs +++ b/src/rect.rs @@ -17,7 +17,7 @@ use std::cmp::PartialOrd; use std::fmt::{self, Formatter}; use std::ops::{Add, Sub, Mul, Div}; -#[derive(Clone, Copy, RustcDecodable, RustcEncodable, PartialEq)] +#[derive(Clone, Copy, RustcDecodable, RustcEncodable, PartialEq, Deserialize, Serialize)] pub struct Rect { pub origin: Point2D, pub size: Size2D, diff --git a/src/side_offsets.rs b/src/side_offsets.rs index d7f0ae3..3e44b63 100644 --- a/src/side_offsets.rs +++ b/src/side_offsets.rs @@ -15,7 +15,7 @@ use std::ops::Add; /// A group of side offsets, which correspond to top/left/bottom/right for borders, padding, /// and margins in CSS. -#[derive(Clone, Copy, PartialEq, Debug)] +#[derive(Clone, Copy, PartialEq, Debug, Deserialize, Serialize)] pub struct SideOffsets2D { pub top: T, pub right: T, diff --git a/src/size.rs b/src/size.rs index 5939363..2234aed 100644 --- a/src/size.rs +++ b/src/size.rs @@ -14,7 +14,7 @@ use num_lib::NumCast; use std::fmt::{self, Formatter}; use std::ops::{Mul, Div}; -#[derive(Clone, Copy, RustcDecodable, RustcEncodable, PartialEq)] +#[derive(Clone, Copy, RustcDecodable, RustcEncodable, PartialEq, Deserialize, Serialize)] pub struct Size2D { pub width: T, pub height: T