diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-04-21 21:17:25 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-04-21 21:17:25 +0200 |
| commit | 72478946c261f04754c11f8a6abf6eb0f43dea31 (patch) | |
| tree | b2a621804d39ace4e57ec4a51b34d40bb4a98987 /src/geom | |
| parent | df58a4d89b67783b1ffc5c3b7282302d59db8c70 (diff) | |
Make frames serializable 📚
This also makes serialization support non-optional since it's too much feature-management for too little benefit.
Diffstat (limited to 'src/geom')
| -rw-r--r-- | src/geom/angle.rs | 10 | ||||
| -rw-r--r-- | src/geom/length.rs | 13 | ||||
| -rw-r--r-- | src/geom/path.rs | 7 | ||||
| -rw-r--r-- | src/geom/point.rs | 4 | ||||
| -rw-r--r-- | src/geom/size.rs | 4 |
5 files changed, 18 insertions, 20 deletions
diff --git a/src/geom/angle.rs b/src/geom/angle.rs index 938141ee..f1db841c 100644 --- a/src/geom/angle.rs +++ b/src/geom/angle.rs @@ -69,7 +69,7 @@ impl Display for Angle { impl Debug for Angle { fn fmt(&self, f: &mut Formatter) -> fmt::Result { let unit = AngularUnit::Deg; - write!(f, "{:?}{:?}", self.to_unit(unit), unit) + write!(f, "{}{}", self.to_unit(unit), unit) } } @@ -134,7 +134,7 @@ impl Sum for Angle { } } /// Different units of angular measurement. -#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] pub enum AngularUnit { /// Radians. Rad, @@ -161,12 +161,6 @@ impl Display for AngularUnit { } } -impl Debug for AngularUnit { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - Display::fmt(self, f) - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/src/geom/length.rs b/src/geom/length.rs index 1c2a5f86..c75f79b5 100644 --- a/src/geom/length.rs +++ b/src/geom/length.rs @@ -1,7 +1,10 @@ use super::*; +use serde::{Deserialize, Serialize}; + /// An absolute length. -#[derive(Default, Copy, Clone, PartialEq, PartialOrd)] +#[derive(Default, Copy, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] +#[serde(transparent)] pub struct Length { /// The length in raw units. raw: f64, @@ -192,7 +195,7 @@ impl Sum for Length { } /// Different units of length measurement. -#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] pub enum LengthUnit { /// Points. Pt, @@ -227,12 +230,6 @@ impl Display for LengthUnit { } } -impl Debug for LengthUnit { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - Display::fmt(self, f) - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/src/geom/path.rs b/src/geom/path.rs index c9fcf1c0..dcabb9cf 100644 --- a/src/geom/path.rs +++ b/src/geom/path.rs @@ -1,11 +1,14 @@ use super::*; +use serde::{Deserialize, Serialize}; + /// A bezier path. -#[derive(Default, Debug, Clone, PartialEq)] +#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(transparent)] pub struct Path(pub Vec<PathElement>); /// An element in a bezier path. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum PathElement { MoveTo(Point), LineTo(Point), diff --git a/src/geom/point.rs b/src/geom/point.rs index 29298565..5ed8bf1d 100644 --- a/src/geom/point.rs +++ b/src/geom/point.rs @@ -1,7 +1,9 @@ use super::*; +use serde::{Deserialize, Serialize}; + /// A point in 2D. -#[derive(Default, Copy, Clone, PartialEq)] +#[derive(Default, Copy, Clone, PartialEq, Serialize, Deserialize)] pub struct Point { /// The x coordinate. pub x: Length, diff --git a/src/geom/size.rs b/src/geom/size.rs index 2dd34a87..0a64e6b9 100644 --- a/src/geom/size.rs +++ b/src/geom/size.rs @@ -1,7 +1,9 @@ use super::*; +use serde::{Deserialize, Serialize}; + /// A size in 2D. -#[derive(Default, Copy, Clone, PartialEq)] +#[derive(Default, Copy, Clone, PartialEq, Serialize, Deserialize)] pub struct Size { /// The width. pub width: Length, |
