pub fn build_deltas_tree<'a>(
    latest_version: Version,
    deltas: impl std::iter::Iterator<Item = &'a (Version, Vec<u8>)>,
) -> LabeledTree<Vec<u8>> {
    let mut deltas_map = FlatMap::new();
    for (version, bytes) in deltas {
        deltas_map
            .try_append(
                Label::from(version.to_be_bytes()),
                LabeledTree::Leaf(bytes.clone()),
            )
            .unwrap_or_else(|(v, _)| {
                panic!(
                    "Versions must be sorted, got decreasing version sequence [{:?}, {:?}]",
                    deltas_map.last_key().unwrap(),
                    v
                )
            });
    }
    let root = flatmap!(
        Label::from("current_version") => num_leaf(latest_version),
        Label::from("delta") => LabeledTree::SubTree(deltas_map),
    );
    LabeledTree::SubTree(root)
}
/// Constructs a labeled tree encoding the specified range of deltas.
Constructs a labeled tree encoding the specified range of deltas.
Constructs a labeled tree encoding the specified range of deltas .
pub fn build_deltas_tree<'a>(
    latest_version: Version,
    deltas: impl std::iter::Iterator<Item = &'a (Version, Vec<u8>)>,
) -> LabeledTree<Vec<u8>> {
    let mut deltas_map = FlatMap::new();
    for (version, bytes) in deltas {
        deltas_map
            .try_append(
                Label::from(version.to_be_bytes()),
                LabeledTree::Leaf(bytes.clone()),
            )
            .unwrap_or_else(|(v, _)| {
                panic!(
                    "Versions must be sorted, got decreasing version sequence [{:?}, {:?}]",
                    deltas_map.last_key().unwrap(),
                    v
                )
            });
    }
    let root = flatmap!(
        Label::from("current_version") => num_leaf(latest_version),
        Label::from("delta") => LabeledTree::SubTree(deltas_map),
    );
    LabeledTree::SubTree(root)
}
pub fn build_deltas_tree < ' a > ( latest_version : Version , deltas : impl std :: iter :: Iterator < Item = & ' a ( Version , Vec < u8 > ) > , ) -> LabeledTree < Vec < u8 > > { let mut deltas_map = FlatMap :: new ( ) ; for ( version , bytes ) in deltas { deltas_map . try_append ( Label :: from ( version . to_be_bytes ( ) ) , LabeledTree :: Leaf ( bytes . clone ( ) ) , ) . unwrap_or_else ( | ( v , _ ) | { panic ! ( " " deltas_map last_key ( ) unwrap ( ) v ) } ) ; } let root = flatmap ! ( Label from ( " " ) num_leaf ( latest_version ) Label from ( " " ) LabeledTree SubTree ( deltas_map ) ) ; LabeledTree :: SubTree ( root ) }
Constructs a labeled tree encoding the specified range of deltas.
Constructs a labeled tree encoding the specified range of deltas .
latest_version
Version
deltas
impl std::iter::Iterator<Item = &'a (Version, Vec<u8>)>
latest_version
Version
deltas
impl std::iter::Iterator<Item = &'a (Version, Vec<u8>)>