ArchiveIndex

Struct ArchiveIndex 

Source
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

Source

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.

Source

pub fn root(&self) -> Dir<'_>

Get the root directory of the archive.

Source

pub fn get_path<I>(&self, path: I) -> Option<Inode<'_>>
where I: IntoIterator, I::Item: AsRef<[u8]>,

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();
Source

pub fn inodes( &self, ) -> impl ExactSizeIterator<Item = Inode<'_>> + DoubleEndedIterator + '_

Get an iterator over all inodes in the archive, in ascending inode number.

Source

pub fn directories( &self, ) -> impl ExactSizeIterator<Item = Dir<'_>> + DoubleEndedIterator + '_

Get an iterator over all directory inodes in the archive, in ascending inode number.

Source

pub fn get_inode(&self, inode_num: u32) -> Option<Inode<'_>>

Lookup an inode by its inode number.

Source

pub fn section_index(&self) -> &[SectionIndexEntry]

Get the low-level section index.

Trait Implementations§

Source§

impl Debug for ArchiveIndex

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.