Expand description
Serde with modules for BTreeMap fields containing u64 keys and/or values.
Unlike bare u64 fields (handled automatically by #[json_safe_fields]), map
fields need explicit #[serde(with = "...")] annotations because the macro
cannot inject serde(with) into generic container internals.
§When to use
If a #[json_safe_fields]-annotated struct has a BTreeMap<K, u64> field,
the compile-time JsonSafeFields check will fail (u64 doesn’t implement the
trait). Add one of these modules as a serde(with) annotation to fix it.
§Available modules
json_safe_u64_u64_map—BTreeMap<u64, u64>json_safe_identifier_u64_map—BTreeMap<Identifier, u64>json_safe_generic_u64_value_map—BTreeMap<K, u64>for any serializable keyjson_safe_u64_nested_identifier_u64_map—BTreeMap<u64, BTreeMap<Identifier, u64>>
§Behavior
Same as safe_integer.rs: uses is_human_readable() to only stringify in
JSON mode. platform_value and bincode stay native.
Modules§
- json_
safe_ generic_ u64_ value_ map - Generic serde
withmodule forBTreeMap<K, u64>fields where K is any serializable/deserializable key type. - json_
safe_ identifier_ u64_ map - Serde
withmodule forBTreeMap<Identifier, u64>fields. - json_
safe_ u64_ nested_ identifier_ u64_ map - Serde
withmodule forBTreeMap<u64, BTreeMap<Identifier, u64>>fields. - json_
safe_ u64_ u64_ map - Serde
withmodule forBTreeMap<u64, u64>fields.