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
impl File
pub const fn location(&self) -> FileLocation
sourcepub const fn offset(&self) -> Option<usize>
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());
sourcepub const fn unpacked(&self) -> bool
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`!");
}
sourcepub const fn executable(&self) -> bool
pub const fn executable(&self) -> bool
Whether this file is executable or not.
Example
println!(
"File is{} an executable",
if file.executable() { "" } else { " not" }
);
sourcepub const fn integrity(&self) -> Option<&FileIntegrity>
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<'de> Deserialize<'de> for File
impl<'de> Deserialize<'de> for File
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 PartialEq for File
impl PartialEq for File
impl Eq for File
impl StructuralEq for File
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more