Struct popcap_pak::Pak
source · pub struct Pak<'a> {
pub entries: Vec<Entry<'a>>,
}
Expand description
An in-memory PAK file.
It may reference borrowed data to avoid decrypting the entire file in memory all at once.
Fields§
§entries: Vec<Entry<'a>>
All entries in this PAK file.
This will likely become private in the future and replaced by safer ways to interact with entries.
Implementations§
source§impl<'a> Pak<'a>
impl<'a> Pak<'a>
sourcepub fn from_read<R>(reader: R) -> Result<Pak<'static>, PakError>where
R: Read,
pub fn from_read<R>(reader: R) -> Result<Pak<'static>, PakError>where
R: Read,
Read a PAK file from a reader.
Pak::from_bytes
should probably be preferred, as it is faster to load upfront, though reading takes slightly longer
and manipulations will incur memory allocations and expensisve copying/decryption.
§Returns
Returns a PAK file with ownership over is data, decrypting it all upfront.
sourcepub fn from_bytes(bytes: &'a [u8]) -> Result<Pak<'a>, PakError>
pub fn from_bytes(bytes: &'a [u8]) -> Result<Pak<'a>, PakError>
Read a PAK file from a byte slice.
§Returns
Returns a PAK file that borrows sections of data from the slice.
Compared to Pak::from_read
,
this takes less time to load,
but reading takes slightly longer and manipulations require copying and decrypting the data.
sourcepub fn into_owned(self) -> Pak<'static>
pub fn into_owned(self) -> Pak<'static>
Takes ownership of all data,
decrypting it and returing a Pak
that is guaranteed to not reference external data.