use crate::digest::ValueDigest;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Serialize, Deserialize, Clone)]
pub struct Proof<const N: usize> {
pub path: Vec<ValueDigest<N>>, pub target_hash: Option<ValueDigest<N>>, }
impl<const N: usize> fmt::Debug for Proof<N> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Proof")
.field(
"path",
&self
.path
.iter()
.map(|digest| {
let bytes = digest.as_bytes();
if bytes.len() > 8 {
format!("{bytes:02x?}...")
} else {
format!("{bytes:02x?}")
}
})
.collect::<Vec<_>>(),
)
.field(
"target_hash",
&self.target_hash.as_ref().map(|digest| {
let bytes = digest.as_bytes();
if bytes.len() > 8 {
format!("{bytes:02x?}...")
} else {
format!("{bytes:02x?}")
}
}),
)
.finish()
}
}