ckb_fixed_hash_core/
lib.rs

1//! Provide several fixed-length binary data, aka fixed-sized hashes.
2//!
3//! # Notice
4//!
5//! **This is an internal crate used by crate [`ckb_fixed_hash`], do not use this crate directly.**
6//!
7//! All structs and the module [`error`](error/index.html) in this crate are re-exported in crate [`ckb_fixed_hash`].
8//!
9//! And you can found examples in crate [`ckb_fixed_hash`].
10//!
11//! [`ckb_fixed_hash`]: ../ckb_fixed_hash/index.html
12
13use schemars::JsonSchema;
14
15pub mod error;
16
17mod impls;
18mod serde;
19mod std_cmp;
20mod std_convert;
21mod std_default;
22mod std_fmt;
23mod std_hash;
24mod std_str;
25
26#[cfg(test)]
27mod tests;
28
29/// The 20-byte fixed-length binary data.
30///
31/// The name comes from the number of bits in the data.
32///
33/// In JSONRPC, it is encoded as a 0x-prefixed hex string.
34#[derive(Clone)]
35pub struct H160(pub [u8; 20]);
36
37/// The 32-byte fixed-length binary data.
38///
39/// The name comes from the number of bits in the data.
40///
41/// In JSONRPC, it is encoded as a 0x-prefixed hex string.
42#[derive(Clone, JsonSchema)]
43pub struct H256(pub [u8; 32]);
44
45/// The 64-byte fixed-length binary data.
46///
47/// The name comes from the number of bits in the data.
48///
49/// In JSONRPC, it is encoded as a 0x-prefixed hex string.
50#[derive(Clone)]
51pub struct H512(pub [u8; 64]);
52
53/// The 65-byte fixed-length binary data.
54///
55/// The name comes from the number of bits in the data.
56///
57/// In JSONRPC, it is encoded as a 0x-prefixed hex string.
58#[derive(Clone)]
59pub struct H520(pub [u8; 65]);