Implement SerializableState for hashes
The internal state of different hashes can be used for serialization.
Could you please suggest the best solution for tests if the expected values are very long?
digest::hash_serialization_test!(md5_serialization, Md5,
hex!("e5ca2295db93d6dd07ab990fcad2219e00000000000000010113000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"));
digest::hash_serialization_test!(
md5_serialization,
Md5,
[
0xe5, 0xca, 0x22, 0x95, 0xdb, 0x93, 0xd6, 0xdd, 0x07, 0xab, 0x99, 0x0f, 0xca, 0xd2, 0x21,
0x9e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x13, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]
);
You can split it into several lines:
let bytes = hex!(
"0001020304050607"
"08090a0b0c0d0e0f"
);
// equivalent to:
let bytes = hex!("000102030405060708090a0b0c0d0e0f");
It requires hex-literal v0.3.3.
Is it okay if I bump hex-literal? This change is moving MSRV of crates to 1.45.
If yes, what is the preferable width of the line?
Ah, I forgot about that. In this case simply use new lines:
let bytes = hex!("
0001020304050607
08090a0b0c0d0e0f
");
Unfortunately, rustfmt does not like it too much, so you may need to add #[rustfmt::ignore] or use an alternative formatting choice.
Merged as #574