MPQ

Struct MPQ 

Source
pub struct MPQ {
    pub archive_header: MPQFileHeader,
    pub user_data: Option<MPQUserData>,
    pub hash_table_entries: Vec<MPQHashTableEntry>,
    pub block_table_entries: Vec<MPQBlockTableEntry>,
    pub encryption_table: HashMap<u32, u32>,
}
Expand description

The main MPQ object that contains the parsed entries

Fields§

§archive_header: MPQFileHeader

The Archive Header containing format version, the offsets for the block table and hash table.

§user_data: Option<MPQUserData>

The Archive may contain MPQUserData, which is at the start of the file.

§hash_table_entries: Vec<MPQHashTableEntry>

The hash table entries, after decryption and parsing

§block_table_entries: Vec<MPQBlockTableEntry>

The block table entries, after decryption and parsing

§encryption_table: HashMap<u32, u32>

The internal MPQ encryption table.

Implementations§

Source§

impl MPQ

Source

pub fn mpq_string_hash( encryption_table: &HashMap<u32, u32>, location: &str, hash_type: MPQHashType, ) -> Result<u32, MPQParserError>

Hash a string using MPQ’s hash function

_hash on MPyQ This function doesn’t use self as the Builder also needs to access the same functionality.

Source

pub fn get_hash_table_entry( &self, filename: &str, ) -> Result<MPQHashTableEntry, MPQParserError>

Get the hash table entry corresponding to a given filename.

A filename is hashed with both MPQHashType::HashA and MPQHashType::HashB to uniquely identify the filename in the archive

Source

pub fn decompress(input: &[u8]) -> MPQResult<&[u8], Vec<u8>>

Read the compression type and decompress file data accordingly.

Source

pub fn read_mpq_file_sector<'a>( &'a self, filename: &str, force_decompress: bool, orig_input: &'a [u8], ) -> MPQResult<&'a [u8], Vec<u8>>

Reads an embedded file inside the MPQ archive.

Source

pub fn mpq_data_decrypt<'a>( encryption_table: &'a HashMap<u32, u32>, data: &'a [u8], key: u32, ) -> IResult<&'a [u8], Vec<u8>>

Decrypt hash or block table or a sector.

_decrypt on MPyQ

Source

pub fn get_files( &self, orig_input: &[u8], ) -> Result<Vec<(String, usize)>, MPQParserError>

Returns the list of filenames and their respective size as contained in the MPQ archive.

Trait Implementations§

Source§

impl Debug for MPQ

Source§

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

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

impl Default for MPQ

Source§

fn default() -> MPQ

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

Auto Trait Implementations§

§

impl Freeze for MPQ

§

impl RefUnwindSafe for MPQ

§

impl Send for MPQ

§

impl Sync for MPQ

§

impl Unpin for MPQ

§

impl UnwindSafe for MPQ

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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>,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more