Skip to main content

Module decimal_serde

Module decimal_serde 

Source
Expand description

Serde helper module for #[serde(with = "...")] field annotations.

Use this module when you want to control serialisation of a D38 field on a struct that derives Serialize / Deserialize:

use decimal_scaled::D38;

#[derive(serde::Serialize, serde::Deserialize)]
struct MyStruct {
#[serde(with = "decimal_scaled::serde_helpers::decimal_serde")]
length: D38<12>,
}

The free functions delegate to the inherent Serialize / Deserialize impls; they exist so users can annotate #[serde(with = ...)] on fields in generic containing types or in newtype wrappers where the trait impl may be shadowed.

Structs§

DecimalVisitor
Visitor that backs deserialize. Public so external helper modules can reuse it under custom #[serde(deserialize_with)] shapes.

Functions§

deserialize
Deserialise a D38 using the wire format.
serialize
Serialise v using the D38 wire format.