pub fn from_bytes(bytes: &[u8]) -> Result<Self, MerkleTreeError> {
        let mut u32_bytes = [0u8; 4];
        u32_bytes.copy_from_slice(&bytes[..4]);
        let n = usize::try_from(u32::from_be_bytes(u32_bytes))
            .expect("Library should be build in 32 bit targets or higher");
        let num_nodes = n + n - 1;
        let mut nodes = Vec::with_capacity(num_nodes);
        for i in 0..num_nodes {
            nodes.push(bytes[4 + i * D::output_size()..4 + (i + 1) * D::output_size()].to_vec());
        }
        Ok(Self {
            nodes,
            leaf_off: num_nodes - n,
            n,
            hasher: PhantomData::default(),
        })
    }
/// Try to convert a byte string into a `MerkleTree`.
Try to convert a byte string into a `MerkleTree`.
Try to convert a byte string into a ` MerkleTree ` .
pub fn from_bytes(bytes: &[u8]) -> Result<Self, MerkleTreeError> {
        let mut u32_bytes = [0u8; 4];
        u32_bytes.copy_from_slice(&bytes[..4]);
        let n = usize::try_from(u32::from_be_bytes(u32_bytes))
            .expect("Library should be build in 32 bit targets or higher");
        let num_nodes = n + n - 1;
        let mut nodes = Vec::with_capacity(num_nodes);
        for i in 0..num_nodes {
            nodes.push(bytes[4 + i * D::output_size()..4 + (i + 1) * D::output_size()].to_vec());
        }
        Ok(Self {
            nodes,
            leaf_off: num_nodes - n,
            n,
            hasher: PhantomData::default(),
        })
    }
pub fn from_bytes ( bytes : & [ u8 ] ) -> Result < Self , MerkleTreeError > { let mut u32_bytes = [ 0u8 ; 4 ] ; u32_bytes . copy_from_slice ( & bytes [ .. 4 ] ) ; let n = usize :: try_from ( u32 :: from_be_bytes ( u32_bytes ) ) . expect ( " " ) ; let num_nodes = n + n - 1 ; let mut nodes = Vec :: with_capacity ( num_nodes ) ; for i in 0 .. num_nodes { nodes . push ( bytes [ 4 + i * D :: output_size ( ) .. 4 + ( i + 1 ) * D :: output_size ( ) ] . to_vec ( ) ) ; } Ok ( Self { nodes , leaf_off : num_nodes - n , n , hasher : PhantomData :: default ( ) , } ) }
Try to convert a byte string into a `MerkleTree`.
Try to convert a byte string into a ` MerkleTree ` .
bytes
&[u8]