/// Encodes a hash tree into the protobuf representation expected by
/// the registry client.
Encodes a hash tree into the protobuf representation expected by
the registry client.
Encodes a hash tree into the protobuf representation expected by the registry client .
pub fn hash_tree_to_proto(tree: HashTree<'_>) -> pb::MixedHashTree {
    use pb::mixed_hash_tree::{Fork, Labeled, TreeEnum};
    use HashTree::*;
    let tree_enum = match tree {
        Empty => TreeEnum::Empty(()),
        Fork(lr) => TreeEnum::Fork(Box::new(Fork {
            left_tree: Some(Box::new(hash_tree_to_proto(lr.0))),
            right_tree: Some(Box::new(hash_tree_to_proto(lr.1))),
        })),
        Labeled(label, subtree) => TreeEnum::Labeled(Box::new(Labeled {
            label: label.to_vec(),
            subtree: Some(Box::new(hash_tree_to_proto(*subtree))),
        })),
        Leaf(data) => TreeEnum::LeafData(data.into_owned()),
        Pruned(digest) => TreeEnum::PrunedDigest(digest.to_vec()),
    };
    pb::MixedHashTree {
        tree_enum: Some(tree_enum),
    }
}
pub fn hash_tree_to_proto ( tree : HashTree < ' _ > ) -> pb :: MixedHashTree { use pb :: mixed_hash_tree :: { Fork , Labeled , TreeEnum } ; use HashTree :: * ; let tree_enum = match tree { Empty => TreeEnum :: Empty ( ( ) ) , Fork ( lr ) => TreeEnum :: Fork ( Box :: new ( Fork { left_tree : Some ( Box :: new ( hash_tree_to_proto ( lr . 0 ) ) ) , right_tree : Some ( Box :: new ( hash_tree_to_proto ( lr . 1 ) ) ) , } ) ) , Labeled ( label , subtree ) => TreeEnum :: Labeled ( Box :: new ( Labeled { label : label . to_vec ( ) , subtree : Some ( Box :: new ( hash_tree_to_proto ( * subtree ) ) ) , } ) ) , Leaf ( data ) => TreeEnum :: LeafData ( data . into_owned ( ) ) , Pruned ( digest ) => TreeEnum :: PrunedDigest ( digest . to_vec ( ) ) , } ; pb :: MixedHashTree { tree_enum : Some ( tree_enum ) , } }
Encodes a hash tree into the protobuf representation expected by
the registry client.
Encodes a hash tree into the protobuf representation expected by the registry client .
tree
HashTree<'_>