tenderdash_proto/
serializers.rs

1//! Serde JSON serializers
2//!
3//! Serializers and deserializers for a transparent developer experience.
4//!
5//! CAUTION: There are no guarantees for backwards compatibility, this module
6//! should be considered an internal implementation detail which can vanish
7//! without further warning. Use at your own risk.
8//!
9//! All serializers are presented in a
10//! serializers::<Rust_nickname>::<JSON_representation_name> format.
11//!
12//! This example shows how to serialize `Vec<u8>` into different types of
13//! strings:
14//! ```ignore
15//! use serde::{Serialize, Deserialize};
16//! use crate::serializers;
17//!
18//! #[derive(Serialize, Deserialize)]
19//! struct ByteTypes {
20//!
21//!     #[serde(with="serializers::bytes::hexstring")]
22//!     hexbytes: Vec<u8>,
23//!
24//!     #[serde(with="serializers::bytes::base64string")]
25//!     base64bytes: Vec<u8>,
26//!
27//!     #[serde(with="serializers::bytes::string")]
28//!     bytes: Vec<u8>,
29//!
30//! }
31//! ```
32//!
33//! Available serializers:
34//!
35//! | Field Type   | String Format                 | Serializer        |
36//! |--------------|-------------------------------|-------------------|
37//! | `i64`        | e.g. `-5`                     | [`from_str`]      |
38//! | `u64`        | e.g. `100`                    | [`from_str`]      |
39//! | [`Duration`] | Nanoseconds (e.g. `100`)      | [`time_duration`] |
40//! | `Vec<u8>`    | Hexadecimal (e.g. `1AF2B3C4`) | [`hexstring`]     |
41//! | `Vec<u8>`    | Base64-encoded                | [`base64string`]  |
42//! | `Vec<u8>`    | Raw bytes in string           | [`string`]        |
43//!
44//! Notes:
45//! * Any type that has the "FromStr" trait can be serialized into a string with
46//!   serializers::primitives::string.
47//! * serializers::bytes::* deserializes a null value into an empty vec![].
48//!
49//! [`Duration`]: core::time::Duration
50//! [`hexstring`]: bytes::hexstring
51//! [`base64string`]: bytes::base64string
52//! [`string`]: bytes::string
53
54// Todo: remove dead_code allowance as soon as more types are implemented
55#![allow(dead_code)]
56pub mod bytes;
57// FIXME: evicence.rs didn't build, so it's removed for now
58// pub mod evidence;
59pub mod from_str;
60pub mod nullable;
61pub mod optional;
62pub mod optional_from_str;
63pub mod part_set_header_total;
64pub mod time_duration;
65pub mod timestamp;
66pub mod txs;