Skip to main content

Module serialization

Module serialization 

Source
Expand description

Common serialization traits and functions.

This module provides custom serde deserializers and serializers for common patterns encountered when parsing exchange API responses, particularly:

  • Empty strings that should be interpreted as None or zero.
  • Type conversions from strings to primitives.
  • Decimal values represented as strings.

Re-exports§

pub use self::msgpack::FromMsgPack;
pub use self::msgpack::MsgPackSerializable;
pub use self::msgpack::ToMsgPack;

Modules§

decimal
Exact decimal parsing and JSON serialization contracts.
msgpack
Provides MsgPack serialization support for types implementing Serializable.
sorted_hashset
Sorted serialization for AHashSet<T> where element order must be deterministic.

Traits§

Serializable
Represents types which are serializable for JSON specifications.

Functions§

default_false
Serde default value function that returns false.
default_true
Serde default value function that returns true.
deserialize_decimal
Deserializes a Decimal from either a JSON string or number.
deserialize_decimal_from_str
Deserializes a Decimal from a JSON string.
deserialize_decimal_native
Deserializes a Decimal through rust_decimal’s own Deserialize implementation, keeping its rounding and scale.
deserialize_decimal_or_zero
Deserializes a Decimal from a string field that might be empty.
deserialize_decimal_token
Deserializes a Decimal from the source text of a JSON number or numeric string.
deserialize_decimal_token_borrowed
Deserializes a Decimal as deserialize_decimal_token does, borrowing the token from the input instead of copying it.
deserialize_empty_string_as_none
Deserializes an empty string into None.
deserialize_empty_ustr_as_none
Deserializes an empty [Ustr] into None.
deserialize_optional_decimal
Deserializes an Option<Decimal> from a JSON string, number, or null.
deserialize_optional_decimal_from_str
Deserializes an optional Decimal from a string-only field.
deserialize_optional_decimal_or_zero
Deserializes a Decimal from an optional string field, defaulting to zero.
deserialize_optional_decimal_str
Deserializes an optional Decimal from a string field.
deserialize_optional_decimal_token
Deserializes an Option<Decimal> from the source text of a JSON number, numeric string, or null.
deserialize_optional_decimal_token_borrowed
Deserializes an Option<Decimal> as deserialize_optional_decimal_token does, borrowing the token from the input instead of copying it.
deserialize_optional_string_to_u64
Deserializes an optional u64 from a string field.
deserialize_string_to_u8
Deserializes a u8 from a string field.
deserialize_string_to_u64
Deserializes a u64 from a string field.
deserialize_vec_decimal_from_str
Deserializes a Vec<Decimal> from a JSON array of strings.
parse_decimal
Parses a string to Decimal, returning an error if parsing fails.
parse_optional_decimal
Parses an optional string to Decimal, returning None if the string is None or empty.
serialize_decimal_as_str
Serializes a Decimal as a string (lossless, no scientific notation).
serialize_optional_decimal_as_str
Serializes an optional Decimal as a string.
serialize_vec_decimal_as_str
Serializes a Vec<Decimal> as an array of strings.