fn iterate_extents_in_tree<B: ByteSlice, F: FnMut(&Extent) -> Result<(), ParsingError>>(
        &self,
        extent_tree_node: &ExtentTreeNode<B>,
        extent_handler: &mut F,
    ) -> Result<(), ParsingError> {
        let block_size = self.block_size()?;

        match extent_tree_node.header.eh_depth.get() {
            0 => {
                self.iterate_extents_in_leaf(extent_tree_node, extent_handler)?;
            }
            1..=4 => {
                for e_index in 0..extent_tree_node.header.eh_ecount.get() {
                    let start: usize = size_of::<Extent>() * e_index as usize;
                    let end = start + size_of::<Extent>();
                    let e = ExtentIndex::to_struct_ref(
                        &(extent_tree_node.entries)[start..end],
                        ParsingError::InvalidExtent(start as u64),
                    )?;

                    let next_level_offset = e.target_block_num() as u64 * block_size;

                    let next_extent_header = ExtentHeader::from_reader_with_offset(
                        self.reader.clone(),
                        next_level_offset,
                        ParsingError::InvalidExtent(next_level_offset),
                    )?;

                    let entry_count = next_extent_header.eh_ecount.get() as usize;
                    let entry_size = match next_extent_header.eh_depth.get() {
                        0 => size_of::<Extent>(),
                        _ => size_of::<ExtentIndex>(),
                    };
                    let node_size = size_of::<ExtentHeader>() + (entry_count * entry_size);

                    let mut data = vec![0u8; node_size];
                    self.reader.read(next_level_offset, data.as_mut_slice())?;

                    let next_level_node = ExtentTreeNode::parse(data.as_slice())
                        .ok_or_else(|| ParsingError::InvalidExtent(next_level_offset))?;

                    self.iterate_extents_in_tree(&next_level_node, extent_handler)?;
                }
            }
            _ => return Err(ParsingError::InvalidExtentHeader),
        };

        Ok(())
    }
/// Handles traversal down an extent tree.
Handles traversal down an extent tree.
Handles traversal down an extent tree .
fn iterate_extents_in_tree<B: ByteSlice, F: FnMut(&Extent) -> Result<(), ParsingError>>(
        &self,
        extent_tree_node: &ExtentTreeNode<B>,
        extent_handler: &mut F,
    ) -> Result<(), ParsingError> {
        let block_size = self.block_size()?;
        match extent_tree_node.header.eh_depth.get() {
            0 => {
                self.iterate_extents_in_leaf(extent_tree_node, extent_handler)?;
            }
            1..=4 => {
                for e_index in 0..extent_tree_node.header.eh_ecount.get() {
                    let start: usize = size_of::<Extent>() * e_index as usize;
                    let end = start + size_of::<Extent>();
                    let e = ExtentIndex::to_struct_ref(
                        &(extent_tree_node.entries)[start..end],
                        ParsingError::InvalidExtent(start as u64),
                    )?;
                    let next_level_offset = e.target_block_num() as u64 * block_size;
                    let next_extent_header = ExtentHeader::from_reader_with_offset(
                        self.reader.clone(),
                        next_level_offset,
                        ParsingError::InvalidExtent(next_level_offset),
                    )?;
                    let entry_count = next_extent_header.eh_ecount.get() as usize;
                    let entry_size = match next_extent_header.eh_depth.get() {
                        0 => size_of::<Extent>(),
                        _ => size_of::<ExtentIndex>(),
                    };
                    let node_size = size_of::<ExtentHeader>() + (entry_count * entry_size);
                    let mut data = vec![0u8; node_size];
                    self.reader.read(next_level_offset, data.as_mut_slice())?;
                    let next_level_node = ExtentTreeNode::parse(data.as_slice())
                        .ok_or_else(|| ParsingError::InvalidExtent(next_level_offset))?;
                    self.iterate_extents_in_tree(&next_level_node, extent_handler)?;
                }
            }
            _ => return Err(ParsingError::InvalidExtentHeader),
        };
        Ok(())
    }
fn iterate_extents_in_tree < B : ByteSlice , F : FnMut ( & Extent ) -> Result < ( ) , ParsingError > > ( & self , extent_tree_node : & ExtentTreeNode < B > , extent_handler : & mut F , ) -> Result < ( ) , ParsingError > { let block_size = self . block_size ( ) ? ; match extent_tree_node . header . eh_depth . get ( ) { 0 => { self . iterate_extents_in_leaf ( extent_tree_node , extent_handler ) ? ; } 1 ..= 4 => { for e_index in 0 .. extent_tree_node . header . eh_ecount . get ( ) { let start : usize = size_of :: < Extent > ( ) * e_index as usize ; let end = start + size_of :: < Extent > ( ) ; let e = ExtentIndex :: to_struct_ref ( & ( extent_tree_node . entries ) [ start .. end ] , ParsingError :: InvalidExtent ( start as u64 ) , ) ? ; let next_level_offset = e . target_block_num ( ) as u64 * block_size ; let next_extent_header = ExtentHeader :: from_reader_with_offset ( self . reader . clone ( ) , next_level_offset , ParsingError :: InvalidExtent ( next_level_offset ) , ) ? ; let entry_count = next_extent_header . eh_ecount . get ( ) as usize ; let entry_size = match next_extent_header . eh_depth . get ( ) { 0 => size_of :: < Extent > ( ) , _ => size_of :: < ExtentIndex > ( ) , } ; let node_size = size_of :: < ExtentHeader > ( ) + ( entry_count * entry_size ) ; let mut data = vec ! [ 0u8 node_size ] ; self . reader . read ( next_level_offset , data . as_mut_slice ( ) ) ? ; let next_level_node = ExtentTreeNode :: parse ( data . as_slice ( ) ) . ok_or_else ( | | ParsingError :: InvalidExtent ( next_level_offset ) ) ? ; self . iterate_extents_in_tree ( & next_level_node , extent_handler ) ? ; } } _ => return Err ( ParsingError :: InvalidExtentHeader ) , } ; Ok ( ( ) ) }
Handles traversal down an extent tree.
Handles traversal down an extent tree .
&self
extent_tree_node
&ExtentTreeNode<B>
extent_handler
&mut F
&self
extent_tree_node
&ExtentTreeNode<B>
extent_handler
&mut F