diff --git a/Cargo.toml b/Cargo.toml index 5fa66e5..9cd9884 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gfx-maths" -version = "0.2.1" +version = "0.2.2" authors = [ "Robin Quint" ] edition = "2018" description = "Implementations for the most essential Graphics Math operations" @@ -17,6 +17,7 @@ categories = [ [dependencies] auto_ops = "0.3.0" +serde = { version="1.0.127", features=["derive"], optional=true } [features] default = [] diff --git a/src/mat4.rs b/src/mat4.rs index 2f79739..f79924e 100644 --- a/src/mat4.rs +++ b/src/mat4.rs @@ -8,6 +8,7 @@ use crate::{Quaternion, Vec3, Vec4}; /// as expected by OpenGL and accepted by all other APIs. /// To change this, use feature `mat-row-major` #[derive(Debug, Clone, Copy, PartialEq)] +#[cfg_attr(feature="serde", derive(serde::Serialize, serde::Deserialize))] #[repr(C)] pub struct Mat4 { pub values: [f32; 4*4], diff --git a/src/quaternion.rs b/src/quaternion.rs index 57c7ea2..df255e5 100644 --- a/src/quaternion.rs +++ b/src/quaternion.rs @@ -3,6 +3,7 @@ use crate::Vec3; use auto_ops::*; #[derive(Debug, Clone, Copy, PartialEq)] +#[cfg_attr(feature="serde", derive(serde::Serialize, serde::Deserialize))] #[repr(C)] pub struct Quaternion { pub x: f32, diff --git a/src/vec2.rs b/src/vec2.rs index 40cd4a0..a9646ce 100644 --- a/src/vec2.rs +++ b/src/vec2.rs @@ -3,6 +3,7 @@ use std::ops::Neg; use auto_ops::*; #[derive(Debug, Clone, Copy, PartialEq)] +#[cfg_attr(feature="serde", derive(serde::Serialize, serde::Deserialize))] #[repr(C)] pub struct Vec2 { pub x: f32, diff --git a/src/vec3.rs b/src/vec3.rs index dd83998..07ae857 100644 --- a/src/vec3.rs +++ b/src/vec3.rs @@ -3,6 +3,7 @@ use std::ops::Neg; use auto_ops::*; #[derive(Debug, Clone, Copy, PartialEq)] +#[cfg_attr(feature="serde", derive(serde::Serialize, serde::Deserialize))] #[repr(C)] pub struct Vec3 { pub x: f32, diff --git a/src/vec4.rs b/src/vec4.rs index 0412af4..2ff1ebc 100644 --- a/src/vec4.rs +++ b/src/vec4.rs @@ -3,6 +3,7 @@ use std::ops::Neg; use auto_ops::*; #[derive(Debug, Clone, Copy, PartialEq)] +#[cfg_attr(feature="serde", derive(serde::Serialize, serde::Deserialize))] #[repr(C)] pub struct Vec4 { pub x: f32,