Archive

Struct Archive 

Source
pub struct Archive<R: AsyncRead + AsyncSeek + Unpin> { /* private fields */ }
Expand description

Generic asar archive reader.

It supports any reader that implements AsyncRead, AsyncSeek and Unpin, and adds more methods if the reader implements Send or (Local)Duplicable.

Implementations§

Source§

impl<R: AsyncRead + AsyncSeek + Unpin> Archive<R>

Source

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

Parses an asar archive into Archive.

Source

pub fn reader(&self) -> &R

Returns a reference to its inner reader.

Source

pub fn reader_mut(&mut self) -> &mut R

Returns mutable reference to its inner reader.

It is mostly OK to seek the reader’s cursor, since every time accessing its file will reset the cursor to the file’s position. However, write access will compromise Archive’s functionality. Use with great care!

Source

pub fn into_reader(self) -> R

Drops the inner state and returns the reader.

Source§

impl Archive<DuplicableFile>

Source

pub async fn new_from_file(path: impl Into<PathBuf>) -> Result<Self>

Available on crate feature fs only.

Opens a file and parses it into Archive.

Source§

impl<R: AsyncRead + AsyncSeek + Unpin> Archive<R>

Source

pub async fn get(&mut self, path: &str) -> Result<File<&mut R>>

Returns a file from the archive by taking mutable reference.

Source

pub fn get_entry(&self, path: &str) -> Option<&Entry>

Returns the entry (“metadata”) of specified path.

Source§

impl<R: AsyncRead + AsyncSeek + Duplicable + Unpin> Archive<R>

Source

pub async fn get_owned(&self, path: &str) -> Result<File<R>>

Returns a file from the archive by duplicating the inner reader.

Contrary to Archive::get, it allows multiple read access over a single archive by creating a new file handle for every file. Useful when building a virtual file system like how Electron does.

Source§

impl<R: AsyncRead + AsyncSeek + LocalDuplicable + Unpin> Archive<R>

Source

pub async fn get_owned_local(&self, path: &str) -> Result<File<R>>

Returns a file from the archive by duplicating the inner reader, without Sync.

See Archive::get_owned for more information.

Source§

impl<R: AsyncRead + AsyncSeek + Send + Unpin> Archive<R>

Source

pub async fn extract(&mut self, path: impl AsRef<Path>) -> Result<()>

Available on crate feature fs only.

Extracts the archive to a folder.

Source§

impl<R: AsyncRead + AsyncSeek + Unpin> Archive<R>

Source

pub async fn extract_local(&mut self, path: impl AsRef<Path>) -> Result<()>

Available on crate feature fs only.

Extracts the archive to a folder.

This method is intended for R: !Send. Otherwise, use Archive::extract instead.

Trait Implementations§

Source§

impl<R: Debug + AsyncRead + AsyncSeek + Unpin> Debug for Archive<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 Archive<R>
where R: Freeze,

§

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

§

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

§

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

§

impl<R> Unpin for Archive<R>

§

impl<R> UnwindSafe for Archive<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.