显示软件包…
4 个版本
| 0.7.1 | 2021 年 6 月 8 日 |
|---|---|
| 0.7.0 | 2021 年 2 月 18 日 |
| 0.7.0-alpha | 2021 年 3 月 10 日 |
| 0.5.0 | 2021 年 2 月 20 日 |
#2 in #tetsy
1,001 每月下载量
用于 233 个软件包(直接使用 3 个)
38KB
846 代码行
固定哈希
提供构建自定义固定大小哈希类型的宏。
示例
简单的 256 位(32 字节)哈希类型。
use tetsy_fixed_hash::construct_fixed_hash;
construct_fixed_hash! {
/// My 256 bit hash type.
pub struct H256(32);
}
选择添加不同大小哈希之间的转换。
construct_fixed_hash!{ struct H256(32); }
construct_fixed_hash!{ struct H160(20); }
// auto-implement conversions between H256 and H160
impl_fixed_hash_conversions!(H256, H160);
// now use the generated conversions
assert_eq!(H256::from(H160::zero()), H256::zero());
assert_eq!(H160::from(H256::zero()), H160::zero());
可以添加属性到您的类型,例如使它们可序列化。
construct_fixed_hash!{
/// My serializable hash type.
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
struct H160(20);
}
特性
默认情况下,这是一个依赖于标准库的软件包。对于 #[no_std] 环境,如下使用:
tetsy-fixed-hash = { version = "0.3", default-features = false }
可用特性
std:使用标准库而不是核心库。- 使用此特性启用以下特性
rustc-hex/stdrand/stdbyteorder/std
- 默认启用。
- 使用此特性启用以下特性
libc:为PartialEq和Ord的实现使用libc。- 默认启用。
rand:提供基于rand软件包的 API。- 默认启用。
byteorder:提供基于byteorder软件包的 API。- 默认启用。
quickcheck:为哈希类型提供quickcheck实现。- 默认禁用。
api-dummy:为 API 文档生成虚拟哈希类型。- 在
docs.rs上默认启用
- 在
arbitrary:允许从随机的非结构化输入创建哈希。- 默认禁用。
依赖项
~380–660KB
~11K SLoC