pub struct ArchiveIndex { /* private fields */ }Expand description
The index of a DwarFS archive representing the whole hierarchy.
This struct is immutable, and is separated from Archive for easier
lifetime management.
Use Archive::new to parse and create a pair of ArchiveIndex and
Archive.
You usually start at ArchiveIndex::root to get the root directory in the
archive and walking or searching on the directory tree. File content can
be read via AsChunks, or by manually iterating its Chunks and
invokes Chunk::read_cached. You need to supply &mut Archive
corresponding to this index only when reading file contents.
Implementations§
Source§impl ArchiveIndex
impl ArchiveIndex
Sourcepub fn new_with_config<R: ReadAt + Size>(
rdr: &mut SectionReader<R>,
config: &Config,
) -> Result<Self>
pub fn new_with_config<R: ReadAt + Size>( rdr: &mut SectionReader<R>, config: &Config, ) -> Result<Self>
Parse and create the index of a DwarFS archive.
This is a low-level methods. Usually you should use Archive::new to
get a pair of ArchiveIndex and Archive instead.
Sourcepub fn get_path<I>(&self, path: I) -> Option<Inode<'_>>
pub fn get_path<I>(&self, path: I) -> Option<Inode<'_>>
Get the inode under the given path from the root directory of the archive.
use dwarfs::{ArchiveIndex, Inode};
let index: ArchiveIndex;
// These two statements are equivalent.
let baz1: Inode<'_> = index.get_path("src/lib.rs".split('/'))?;
let baz2: Inode<'_> = index.root().get("src")?.inode().as_dir()?.get("lib.rs")?.inode();Sourcepub fn inodes(
&self,
) -> impl ExactSizeIterator<Item = Inode<'_>> + DoubleEndedIterator + '_
pub fn inodes( &self, ) -> impl ExactSizeIterator<Item = Inode<'_>> + DoubleEndedIterator + '_
Get an iterator over all inodes in the archive, in ascending inode number.
Sourcepub fn directories(
&self,
) -> impl ExactSizeIterator<Item = Dir<'_>> + DoubleEndedIterator + '_
pub fn directories( &self, ) -> impl ExactSizeIterator<Item = Dir<'_>> + DoubleEndedIterator + '_
Get an iterator over all directory inodes in the archive, in ascending inode number.
Sourcepub fn get_inode(&self, inode_num: u32) -> Option<Inode<'_>>
pub fn get_inode(&self, inode_num: u32) -> Option<Inode<'_>>
Lookup an inode by its inode number.
Sourcepub fn section_index(&self) -> &[SectionIndexEntry]
pub fn section_index(&self) -> &[SectionIndexEntry]
Get the low-level section index.