mirror of
https://github.com/tlsnotary/rs-merkle.git
synced 2026-01-07 22:13:57 -05:00
feat: serde feature
This commit is contained in:
@@ -8,13 +8,14 @@ license = "Apache-2.0/MIT"
|
|||||||
repository = "https://github.com/antouhou/rs-merkle"
|
repository = "https://github.com/antouhou/rs-merkle"
|
||||||
documentation = "https://docs.rs/rs_merkle/"
|
documentation = "https://docs.rs/rs_merkle/"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
keywords = ["merkle", "tree", "proof", "hash", "multiproof",]
|
keywords = ["merkle", "tree", "proof", "hash", "multiproof"]
|
||||||
exclude = ["/ci/*", "/scripts/*", "/.github/*", "/bors.toml"]
|
exclude = ["/ci/*", "/scripts/*", "/.github/*", "/bors.toml"]
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
sha2 = { version = "0.10", default-features = false }
|
sha2 = { version = "0.10", default-features = false }
|
||||||
|
serde = { version = "1", optional = true, features = ["derive"] }
|
||||||
|
|
||||||
# standard crate data is left out
|
# standard crate data is left out
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
@@ -23,3 +24,4 @@ rayon = "1.5.1"
|
|||||||
[features]
|
[features]
|
||||||
default = ['std']
|
default = ['std']
|
||||||
std = ["sha2/std"]
|
std = ["sha2/std"]
|
||||||
|
serde = ["dep:serde"]
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ use core::convert::TryFrom;
|
|||||||
///
|
///
|
||||||
/// [`Hasher`]: crate::Hasher
|
/// [`Hasher`]: crate::Hasher
|
||||||
/// [`algorithms::Sha256`]: crate::algorithms::Sha256
|
/// [`algorithms::Sha256`]: crate::algorithms::Sha256
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub struct MerkleProof<H> {
|
pub struct MerkleProof<H> {
|
||||||
proof_hashes: Vec<H>,
|
proof_hashes: Vec<H>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use crate::{
|
|||||||
/// roll back to any previously committed state of the tree. This scenario is similar to Git and
|
/// roll back to any previously committed state of the tree. This scenario is similar to Git and
|
||||||
/// can be found in databases and file systems.
|
/// can be found in databases and file systems.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub struct MerkleTree<H> {
|
pub struct MerkleTree<H> {
|
||||||
current_working_tree: PartialTree<H>,
|
current_working_tree: PartialTree<H>,
|
||||||
history: Vec<PartialTree<H>>,
|
history: Vec<PartialTree<H>>,
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ type PartialTreeLayer<H> = Vec<(usize, H)>;
|
|||||||
/// [`MerkleTree`]: crate::MerkleTree
|
/// [`MerkleTree`]: crate::MerkleTree
|
||||||
/// [`MerkleProof`]: crate::MerkleProof
|
/// [`MerkleProof`]: crate::MerkleProof
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub struct PartialTree<H> {
|
pub struct PartialTree<H> {
|
||||||
layers: Vec<Vec<(usize, H)>>,
|
layers: Vec<Vec<(usize, H)>>,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user