PackageReader

Struct PackageReader 

Source
pub struct PackageReader<R: Read + Seek> { /* private fields */ }
Expand description

A package-specialized ZIP reader that is optimized for reading all file names as fast as possible. This reader only accesses file immutably. This reader ignores folders.

If the underlying stream (such as file) is modified while this reader is create, subsequent file reads are really likely to error (will never panic!).

Implementations§

Source§

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

Source

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

Create a package reader with the underlying read+seek implementor.

Source

pub fn clone_with<NewR: Read + Seek>(&self, reader: NewR) -> PackageReader<NewR>

A fast clone of this package reader into a new fully independent reader, this will reuse the file list of the current reader. The caller must ensure that this reader points to the same data as the current reader, if not the case, file informations may be wrong and subsequent file reads are likely to return error, this will never panic and not cause any UB!

Source

pub fn len(&self) -> usize

Return the number of files in the package.

Source

pub fn names(&self) -> impl Iterator<Item = &str> + '_

Return an iterator over all file names in the package. The position of file names in this iterator is the same that can be used when reading from index, using the Self::read_by_index() method.

Source

pub fn index_by_name(&self, file_name: &str) -> Option<usize>

Source

pub fn read_by_name( &mut self, file_name: &str, ) -> Result<PackageFileReader<&mut R>>

Open a package file by its name and return a borrowed reader if successful.

Source

pub fn read_by_index( &mut self, file_index: usize, ) -> Result<PackageFileReader<&mut R>>

Open a package file by its index and return a borrowed reader if successful.

Note that the returned reader has no buffered over the original reader given at construction, you should handle buffering if necessary.

Trait Implementations§

Source§

impl<R: Read + Seek + Debug> Debug for PackageReader<R>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<R> UnwindSafe for PackageReader<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> 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V