Struct asar::header::File

source ·
pub struct File { /* private fields */ }
Expand description

This struct contains details about a file in an asar archive, such as where it is located in the archive, its size, whether its executable or not, and integrity details such as cryptographic hashes.

Implementations§

source§

impl File

source

pub const fn location(&self) -> FileLocation

source

pub const fn offset(&self) -> Option<usize>

The offset from the end of the header that this file is located at.

If this returns None, then the file is ‘unpacked’, meaning it’s not in the archive.

Note that this is represented as a String in the JSON format, but we convert it to/from a usize when we read/write the JSON.

Example
println!("File begins at {:#?}", file.offset());
source

pub const fn unpacked(&self) -> bool

Whether this file is ‘unpacked’ or not.

Unpacked files are stored on the actual file system, adjacent to the asar, in a folder named [asar name].asar.unpacked.

Example
if file.unpacked() {
	println!("File is at `./archive.asar.unpacked/file`!");
}
source

pub const fn size(&self) -> usize

The total size of the file, in bytes.

Example
println!("File is {} bytes", file.size());
source

pub const fn executable(&self) -> bool

Whether this file is executable or not.

Example
println!(
	"File is{} an executable",
	if file.executable() { "" } else { " not" }
);
source

pub const fn integrity(&self) -> Option<&FileIntegrity>

Integrity details of the file, such as hashes.

Example
println!(
	"File hash: {}",
	hex::encode(file.integrity().unwrap().hash())
);

Trait Implementations§

source§

impl Clone for File

source§

fn clone(&self) -> File

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for File

source§

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

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for File

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Hash for File

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for File

source§

fn eq(&self, other: &File) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for File

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for File

source§

impl StructuralEq for File

source§

impl StructuralPartialEq for File

Auto Trait Implementations§

§

impl RefUnwindSafe for File

§

impl Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl UnwindSafe for File

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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,