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>

source

pub fn new() -> Self

Make an empty PAK file.

source

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.

source

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.

source

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.

source

pub fn write_to<W>(&mut self, writer: W) -> Result<(), PakError>
where W: Write,

Writes data to a writeable destination.

This takes &mut self because at the end of this function, all files’ cursors will be at the end of the stream.

Trait Implementations§

source§

impl<'a> Debug for Pak<'a>

source§

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

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

impl<'a> Default for Pak<'a>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'a> PartialEq for Pak<'a>

source§

fn eq(&self, other: &Pak<'a>) -> 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<'a> StructuralPartialEq for Pak<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Pak<'a>

§

impl<'a> RefUnwindSafe for Pak<'a>

§

impl<'a> Send for Pak<'a>

§

impl<'a> Sync for Pak<'a>

§

impl<'a> Unpin for Pak<'a>

§

impl<'a> UnwindSafe for Pak<'a>

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