Struct nom_mpq::builder::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) -> u32

Performs mpq string hashing using the encryption table.

source

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

Uses the encryption table and key to decrypt some bytes

source

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

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

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · 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 Twhere U: From<T>,

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

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