mirror of
https://github.com/BLAKE3-team/BLAKE3
synced 2024-05-27 12:46:02 +02:00
Allow for serialization, and deserialization of
the `Hash` struct when the `serde` feature is enabled.
This commit is contained in:
parent
64747d48ff
commit
c93b630a65
|
@ -77,6 +77,10 @@ no_avx2 = []
|
|||
no_avx512 = []
|
||||
no_neon = []
|
||||
|
||||
# Enable support for serialization, and desrialization of
|
||||
# the `Hash` struct.
|
||||
serde = ["serde/derive"]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
# Document Hasher::update_rayon on docs.rs.
|
||||
features = ["rayon"]
|
||||
|
@ -88,6 +92,7 @@ constant_time_eq = "0.2.4"
|
|||
rayon = { version = "1.2.1", optional = true }
|
||||
cfg-if = "1.0.0"
|
||||
digest = { version = "0.10.1", features = [ "mac" ], optional = true }
|
||||
serde = { version = "1.0.156", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
hex = "0.4.2"
|
||||
|
|
|
@ -119,6 +119,8 @@ use arrayvec::{ArrayString, ArrayVec};
|
|||
use core::cmp;
|
||||
use core::fmt;
|
||||
use platform::{Platform, MAX_SIMD_DEGREE, MAX_SIMD_DEGREE_OR_2};
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// The number of bytes in a [`Hash`](struct.Hash.html), 32.
|
||||
pub const OUT_LEN: usize = 32;
|
||||
|
@ -197,6 +199,7 @@ fn counter_high(counter: u64) -> u32 {
|
|||
/// [`Display`]: https://doc.rust-lang.org/std/fmt/trait.Display.html
|
||||
/// [`FromStr`]: https://doc.rust-lang.org/std/str/trait.FromStr.html
|
||||
#[derive(Clone, Copy, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
|
||||
pub struct Hash([u8; OUT_LEN]);
|
||||
|
||||
impl Hash {
|
||||
|
|
Loading…
Reference in New Issue