Skip to main content

Module serde_impl

Module serde_impl 

Source
Expand description

This module is only available if the serde feature is enabled. It provides various functions which can be used to (fallible) deserialize a valid DynQuantity representation into any type T which implements TryFrom<DynQuantity>. See the docstring of DynQuantity for an overview over all possible representations.

Constants§

SERIALIZE_WITH_UNITS
A thread-local, static variable which enables / disables serialization of quantities with or without units. It is used within the functions serialize_quantity, serialize_opt_quantity, serialize_angle and serialize_opt_angle as a thread-local context to decide whether a quantity should be serialized with or without its units. By default, its value is false, meaning that quantities are serialized without their units. The serialize_with_units function sets it temporarily to true, then performs the actual serialization, and afterwards resets it to false again (return to default behaviour).

Functions§

deserialize_angle
Deserializes an angle from a valid DynQuantity representation (see docstring of DynQuantity). The output value is always in radians.
deserialize_opt_angle
Like deserialize_angle, but deserializes into an Option<f64> instead of a f64.
deserialize_opt_quantity
Like deserialize_quantity, but deserializes into an Option<T> instead of a T implementing TryFrom<DynQuantity>.
deserialize_opt_vec_of_quantities
Like deserialize_vec_of_quantities, but deserializes into an Option<Vec<T>> instead of a Vec<T>.
deserialize_quantity
Deserializes a type T implementing TryFrom<DynQuantity> from a valid DynQuantity representation (see docstring of DynQuantity).
deserialize_vec_of_quantities
Deserializes a vector of T which implements TryFrom<DynQuantity> from:
serialize_angle
Enables serialization of an angle into a string containing both the value and the “rad” unit.
serialize_opt_angle
Like serialize_angle, but serializes an &Option<T> instead of a &T implementing Into<DynQuantity>.
serialize_opt_quantity
Like serialize_quantity, but serializes an &Option<T> instead of a &T implementing Into<DynQuantity>.
serialize_quantity
Enables serialization of a quantity (any type implementing Into<DynQuantity>) into a string containing both the value and the units.
serialize_with_units
A wrapper around a serialization function / closure which enables serialization with units.