library: document serialize module

This commit is contained in:
Antoine Martin 2020-03-22 00:29:24 +01:00
parent 614217d33e
commit 94ab40413a
3 changed files with 10 additions and 0 deletions

View file

@ -1,3 +1,6 @@
//! Helper functions deserialize coefficients.
/// Returns the identity for a f32, i.e. 1.0.
pub fn default_identity() -> f32 { pub fn default_identity() -> f32 {
1. 1.
} }

View file

@ -1,3 +1,5 @@
//! Helper functions to help scene (de)serialization
pub mod vector; pub mod vector;
pub use vector::*; pub use vector::*;

View file

@ -1,6 +1,11 @@
//! Helper functions to deserialize `Vector` values.
use crate::Vector; use crate::Vector;
use serde::de::{Deserialize, Deserializer}; use serde::de::{Deserialize, Deserializer};
/// Deserialize a vector.
///
/// Needs a custom implementation to make sur the vector is normalized when deserialized.
pub fn vector_normalizer<'de, D>(deserializer: D) -> Result<Vector, D::Error> pub fn vector_normalizer<'de, D>(deserializer: D) -> Result<Vector, D::Error>
where where
D: Deserializer<'de>, D: Deserializer<'de>,