Skip to main content

AsarArchive

Struct AsarArchive 

Source
pub struct AsarArchive { /* private fields */ }
Expand description

An ASAR archive that can be read from or written to disk.

§Creating archives

use asar_rust::AsarArchive;
use std::path::Path;

let archive = AsarArchive::pack(Path::new("src"), Path::new("app.asar")).unwrap();

§Reading archives

use asar_rust::AsarArchive;
use std::path::Path;

let archive = AsarArchive::open(Path::new("app.asar")).unwrap();
let files = archive.list().unwrap();
let data = archive.extract_file("main.js").unwrap();

Implementations§

Source§

impl AsarArchive

Source

pub fn pack(src: &Path, dest: &Path) -> Result<Self, AsarError>

Create a new ASAR archive from a directory.

Source

pub fn pack_with_options( src: &Path, dest: &Path, options: CreateOptions, ) -> Result<Self, AsarError>

Create an ASAR archive with custom options.

Source

pub fn open(archive_path: &Path) -> Result<Self, AsarError>

Open an existing ASAR archive for reading.

Source

pub fn raw_header(&self) -> Result<ArchiveHeader, AsarError>

Get the raw archive header.

Source

pub fn list(&self) -> Result<Vec<String>, AsarError>

List all files in the archive.

Source

pub fn list_with_flags( &self, opts: ListOptions, ) -> Result<Vec<String>, AsarError>

List files with pack/unpack state.

Source

pub fn stat( &self, filename: &str, follow_links: bool, ) -> Result<FilesystemEntry, AsarError>

Get metadata for a file in the archive.

Source

pub fn extract_file(&self, filename: &str) -> Result<Vec<u8>, AsarError>

Extract a single file’s contents.

Source

pub fn extract_all(&self, dest: &Path) -> Result<(), AsarError>

Extract all files from the archive to a destination directory.

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.