fn to_packfile_entries(
        &self,
        pack_file: &mut IndexMap<HashOutput, PackFileEntry<'a>>,
    ) -> Result<HashOutput, anyhow::Error> {
        let mut tree = Vec::with_capacity(self.0.len());

        for (name, item) in &self.0 {
            tree.push(match item.as_ref() {
                TreeItem::Blob(hash) => LowLevelTreeItem {
                    kind: TreeItemKind::File,
                    name,
                    hash: *hash,
                },
                TreeItem::Tree(tree) => LowLevelTreeItem {
                    kind: TreeItemKind::Directory,
                    name,
                    // we're essentially working through our tree from the bottom up,
                    // so we can grab the hash of each directory along the way and
                    // reference it from the parent directory
                    hash: tree.to_packfile_entries(pack_file)?,
                },
            });
        }

        // gets the hash of the tree we've just worked on, and
        // pushes it to the packfile
        let tree = PackFileEntry::Tree(tree);
        let hash = tree.hash()?;
        pack_file.insert(hash, tree);

        Ok(hash)
    }
/// Recursively writes the the whole tree out to the given `pack_file`,
/// the tree contains pointers to (hashes of) files contained within a
/// directory, and pointers to other directories.
Recursively writes the the whole tree out to the given `pack_file`,
the tree contains pointers to (hashes of) files contained within a
directory, and pointers to other directories.
Recursively writes the the whole tree out to the given ` pack_file ` the tree contains pointers to ( hashes of ) files contained within a directory and pointers to other directories .
fn to_packfile_entries(
        &self,
        pack_file: &mut IndexMap<HashOutput, PackFileEntry<'a>>,
    ) -> Result<HashOutput, anyhow::Error> {
        let mut tree = Vec::with_capacity(self.0.len());
        for (name, item) in &self.0 {
            tree.push(match item.as_ref() {
                TreeItem::Blob(hash) => LowLevelTreeItem {
                    kind: TreeItemKind::File,
                    name,
                    hash: *hash,
                },
                TreeItem::Tree(tree) => LowLevelTreeItem {
                    kind: TreeItemKind::Directory,
                    name,
                    // we're essentially working through our tree from the bottom up,
                    // so we can grab the hash of each directory along the way and
                    // reference it from the parent directory
                    hash: tree.to_packfile_entries(pack_file)?,
                },
            });
        }
        // gets the hash of the tree we've just worked on, and
        // pushes it to the packfile
        let tree = PackFileEntry::Tree(tree);
        let hash = tree.hash()?;
        pack_file.insert(hash, tree);
        Ok(hash)
    }
fn to_packfile_entries ( & self , pack_file : & mut IndexMap < HashOutput , PackFileEntry < ' a > > , ) -> Result < HashOutput , anyhow :: Error > { let mut tree = Vec :: with_capacity ( self . 0 . len ( ) ) ; for ( name , item ) in & self . 0 { tree . push ( match item . as_ref ( ) { TreeItem :: Blob ( hash ) => LowLevelTreeItem { kind : TreeItemKind :: File , name , hash : * hash , } , TreeItem :: Tree ( tree ) => LowLevelTreeItem { kind : TreeItemKind :: Directory , name , // we're essentially working through our tree from the bottom up, // so we can grab the hash of each directory along the way and // reference it from the parent directory hash : tree . to_packfile_entries ( pack_file ) ? , } , } ) ; } // gets the hash of the tree we've just worked on, and // pushes it to the packfile let tree = PackFileEntry :: Tree ( tree ) ; let hash = tree . hash ( ) ? ; pack_file . insert ( hash , tree ) ; Ok ( hash ) }
Recursively writes the the whole tree out to the given `pack_file`,
the tree contains pointers to (hashes of) files contained within a
directory, and pointers to other directories.
Recursively writes the the whole tree out to the given ` pack_file ` the tree contains pointers to ( hashes of ) files contained within a directory and pointers to other directories .
&self
pack_file
&mut IndexMap<HashOutput, PackFileEntry<'a>>
&self
pack_file
&mut IndexMap<HashOutput, PackFileEntry<'a>>