Skip to main content

ArchiveReader

Struct ArchiveReader 

Source
pub struct ArchiveReader<R> { /* private fields */ }
Expand description

A random-access ZArchive reader.

Implementations§

Source§

impl ArchiveReader<File>

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Opens an archive from the filesystem.

Source§

impl<R: Read + Seek> ArchiveReader<R>

Source

pub fn new(source: R) -> Result<Self>

Opens an archive from any readable, seekable source.

Source

pub fn lookup(&self, path: impl AsRef<[u8]>) -> Option<NodeHandle>

Returns the node at path, using ASCII case-insensitive matching.

Source

pub fn lookup_kind( &self, path: impl AsRef<[u8]>, expected: Option<EntryKind>, ) -> Option<NodeHandle>

Returns the node at path only if it has the requested kind.

Source

pub fn archive_size(&self) -> u64

The total size of the archive file, including its tables and footer.

Source

pub fn compressed_data_size(&self) -> u64

The size of the compressed data section, excluding the tables and footer.

Source

pub fn entry_kind(&self, handle: NodeHandle) -> Option<EntryKind>

Source

pub fn directory_len(&self, handle: NodeHandle) -> Result<u32>

Source

pub fn directory_entry( &self, handle: NodeHandle, index: u32, ) -> Result<DirEntry<'_>>

Source

pub fn directory_entries(&self, handle: NodeHandle) -> Result<Vec<DirEntry<'_>>>

Source

pub fn file_size(&self, handle: NodeHandle) -> Result<u64>

Source

pub fn read_file( &mut self, handle: NodeHandle, offset: u64, buffer: &mut [u8], ) -> Result<usize>

Reads at most buffer.len() bytes beginning at an offset within a file.

Source

pub fn read_file_to_end(&mut self, handle: NodeHandle) -> Result<Vec<u8>>

Reads an entire archived file into memory.

Source

pub fn verify_integrity(&mut self) -> Result<bool>

Verifies the SHA-256 digest stored in the archive footer.

Source

pub fn verify_integrity_with( &mut self, progress: impl FnMut(u64), ) -> Result<bool>

Verifies the footer digest, reporting bytes hashed as it goes.

progress is called with the size of each chunk as it is consumed, so callers can drive a progress indicator over what is otherwise a single long pass across the whole file.

Source

pub fn into_inner(self) -> R

Auto Trait Implementations§

§

impl<R> Freeze for ArchiveReader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for ArchiveReader<R>
where R: RefUnwindSafe,

§

impl<R> Send for ArchiveReader<R>
where R: Send,

§

impl<R> Sync for ArchiveReader<R>
where R: Sync,

§

impl<R> Unpin for ArchiveReader<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for ArchiveReader<R>
where R: UnsafeUnpin,

§

impl<R> UnwindSafe for ArchiveReader<R>
where R: UnwindSafe,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.