pub fn from_bytes(bytes: &[u8]) -> Result<Self, MerkleTreeError> {
        let mut u32_bytes = [0u8; 4];
        u32_bytes.copy_from_slice(&bytes[..4]);
        let len = usize::try_from(u32::from_be_bytes(u32_bytes))
            .expect("Library should be built in 32 bit targets or higher");
        u32_bytes.copy_from_slice(&bytes[4..8]);
        let size_batch = usize::try_from(u32::from_be_bytes(u32_bytes))
            .expect("Library should be built in 32 bit targets or higher");
        let mut indices = Vec::with_capacity(size_batch);

        for slice in bytes[8..8 + 4 * size_batch].chunks(4) {
            u32_bytes.copy_from_slice(slice);
            indices.push(
                usize::try_from(u32::from_be_bytes(u32_bytes))
                    .expect("Library should be built in 32 bit targets or higher"),
            );
        }

        let node_size = D::output_size();
        let mut vec_nodes = Vec::with_capacity(len);
        for slice in bytes[8 + 4 * size_batch..].chunks(node_size) {
            vec_nodes.push(slice.to_vec());
        }

        Ok(Self {
            values: vec_nodes,
            indices,
            hasher: Default::default(),
        })
    }
/// Try to convert a byte string into a `BatchPath`.
Try to convert a byte string into a `BatchPath`.
Try to convert a byte string into a ` BatchPath ` .
pub fn from_bytes(bytes: &[u8]) -> Result<Self, MerkleTreeError> {
        let mut u32_bytes = [0u8; 4];
        u32_bytes.copy_from_slice(&bytes[..4]);
        let len = usize::try_from(u32::from_be_bytes(u32_bytes))
            .expect("Library should be built in 32 bit targets or higher");
        u32_bytes.copy_from_slice(&bytes[4..8]);
        let size_batch = usize::try_from(u32::from_be_bytes(u32_bytes))
            .expect("Library should be built in 32 bit targets or higher");
        let mut indices = Vec::with_capacity(size_batch);
        for slice in bytes[8..8 + 4 * size_batch].chunks(4) {
            u32_bytes.copy_from_slice(slice);
            indices.push(
                usize::try_from(u32::from_be_bytes(u32_bytes))
                    .expect("Library should be built in 32 bit targets or higher"),
            );
        }
        let node_size = D::output_size();
        let mut vec_nodes = Vec::with_capacity(len);
        for slice in bytes[8 + 4 * size_batch..].chunks(node_size) {
            vec_nodes.push(slice.to_vec());
        }
        Ok(Self {
            values: vec_nodes,
            indices,
            hasher: Default::default(),
        })
    }
pub fn from_bytes ( bytes : & [ u8 ] ) -> Result < Self , MerkleTreeError > { let mut u32_bytes = [ 0u8 ; 4 ] ; u32_bytes . copy_from_slice ( & bytes [ .. 4 ] ) ; let len = usize :: try_from ( u32 :: from_be_bytes ( u32_bytes ) ) . expect ( " " ) ; u32_bytes . copy_from_slice ( & bytes [ 4 .. 8 ] ) ; let size_batch = usize :: try_from ( u32 :: from_be_bytes ( u32_bytes ) ) . expect ( " " ) ; let mut indices = Vec :: with_capacity ( size_batch ) ; for slice in bytes [ 8 .. 8 + 4 * size_batch ] . chunks ( 4 ) { u32_bytes . copy_from_slice ( slice ) ; indices . push ( usize :: try_from ( u32 :: from_be_bytes ( u32_bytes ) ) . expect ( " " ) , ) ; } let node_size = D :: output_size ( ) ; let mut vec_nodes = Vec :: with_capacity ( len ) ; for slice in bytes [ 8 + 4 * size_batch .. ] . chunks ( node_size ) { vec_nodes . push ( slice . to_vec ( ) ) ; } Ok ( Self { values : vec_nodes , indices , hasher : Default :: default ( ) , } ) }
Try to convert a byte string into a `BatchPath`.
Try to convert a byte string into a ` BatchPath ` .
bytes
&[u8]