fn deserialize_as_a_unit()

in src/proof.rs [455:505]


    fn deserialize_as_a_unit(
        bytes: &[u8],
        begin: &mut usize,
    ) -> Result<RandomSamplingProof<V>, DecodingError> {
        // Decode the tree index.
        let index = TreeIndex::deserialize_as_a_unit(bytes, 1, begin);
        if let Err(e) = index {
            return Err(e);
        }
        let index = index.unwrap();

        // Decode the padding_num.
        let num = bytes_to_usize(bytes, PADDING_NUM_BYTE_NUM, begin);
        if let Err(e) = num {
            return Err(e);
        }
        let num = num.unwrap();

        // Decode the padding proofs.
        let mut padding_proofs: Vec<V::PaddingProof> = Vec::new();
        for _i in 0..num {
            let padding_proof = V::PaddingProof::deserialize_as_a_unit(bytes, begin);
            if let Err(e) = padding_proof {
                return Err(e);
            }
            padding_proofs.push(padding_proof.unwrap());
        }

        // Decode the Merkle proof.
        let merkle_proof = MerkleProof::<V>::deserialize_as_a_unit(bytes, begin);
        if let Err(e) = merkle_proof {
            return Err(e);
        }
        let merkle_proof = merkle_proof.unwrap();
        // Decode the leaves.
        let mut leaves: Vec<V::ProofNode> = Vec::new();
        for _i in 0..merkle_proof.get_batch_num() {
            let leaf = V::ProofNode::deserialize_as_a_unit(bytes, begin);
            if let Err(e) = leaf {
                return Err(e);
            }
            leaves.push(leaf.unwrap());
        }

        Ok(RandomSamplingProof::<V>::new(
            index[0],
            padding_proofs,
            merkle_proof,
            leaves,
        ))
    }