MPQBuilder

Struct MPQBuilder 

Source
pub struct MPQBuilder {
    pub archive_header: Option<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

A builder for the MPQ parsing, allowing for building the archive progressively

Fields§

§archive_header: Option<MPQFileHeader>

Mandatory field, all MPQ Archives must have an archive header.

§user_data: Option<MPQUserData>

Optional field, not all MPQ Archives have user_data. The user_data contains in the case of Starcrat 2 Replay file, the build information of the version of the game under whcich is played. Different game versions would become different protocols/details, maybe even units?

§hash_table_entries: Vec<MPQHashTableEntry>

The MPQ Hash Table Entries content.

§block_table_entries: Vec<MPQBlockTableEntry>

The MPQ Block Table Entries content

§encryption_table: HashMap<u32, u32>

An encryption table to lookup, this is shared with the crate::MPQ object itself.

Implementations§

Source§

impl MPQBuilder

Source

pub fn new() -> Self

Initializes the Builder, internally creates the encryption table.

Source

pub fn with_archive_header(self, archive_header: MPQFileHeader) -> Self

Sets the archive header field

Source

pub fn with_user_data(self, user_data: Option<MPQUserData>) -> Self

Sets the user data field

Source

pub fn with_hash_table(self, entries: Vec<MPQHashTableEntry>) -> Self

Sets the hash table entries

Source

pub fn with_block_table(self, entries: Vec<MPQBlockTableEntry>) -> Self

Sets the block table entries

Source

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

Performs mpq string hashing using the encryption table.

Source

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

Uses the encryption table and key to decrypt some bytes

Source

pub fn build(self, _orig_input: &[u8]) -> Result<MPQ, MPQParserError>

Consumes self and turns into the final MPQ.

Trait Implementations§

Source§

impl Debug for MPQBuilder

Source§

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

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

impl Default for MPQBuilder

Source§

fn default() -> Self

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

Auto Trait Implementations§

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