Struct infinite_rs::ModuleFile

source ·
pub struct ModuleFile {
    pub header: ModuleHeader,
    pub files: Vec<ModuleFileEntry>,
    pub string_list: Vec<u8>,
    pub resources: Vec<u32>,
    pub blocks: Vec<ModuleBlockEntry>,
    pub file_data_offset: u64,
    /* private fields */
}
Expand description

Module structure which contains the layout of the entire module file. Also stores file_path for re-use in read_tag.

Fields§

§header: ModuleHeader

Info relating to how the other fields should be read.

§files: Vec<ModuleFileEntry>

Metadata regarding compression and layout of files (tags)

§string_list: Vec<u8>

String slice of file names seperated by a null terminator. Does not exist after module version 52.

§resources: Vec<u32>

Indices (?) of resource files present in module.

§blocks: Vec<ModuleBlockEntry>

Uncompressed/compressed blocks making up a file.

§file_data_offset: u64

Offset in BufReader where file data starts.

Implementations§

source§

impl ModuleFile

source

pub fn new() -> Self

Allocate new ModuleFile and set it to default values.

source

pub fn read(&mut self, file_path: String) -> Result<()>

Reads the module file from the given file path. This function reads the entire structure of the module file. It also calculates and stores important offsets within the file.

§Arguments
  • file_path - A string slice that holds the path to the module file
§Returns

Returns Ok(()) if the read operation is successful, or an Err containing the I/O error if any reading operation fails/header checks fail.

source

pub fn read_tag(&mut self, index: usize) -> Result<()>

Reads a specific tag from the module file.

§Arguments
  • index - The index of the file entry to read the tag from
§Returns

Returns Ok(()) if the read operation is successful, or an (anyhow) Error containing the I/O error if any reading operation fails.

source

pub fn read_tag_from_id(&mut self, global_id: i32) -> Result<Option<usize>>

Searches for the index of the tag given the global_id. Reads the tag using read_tag and stores it in the index.

§Arguments
  • global_id - The global tag ID of the file to find.
§Returns

Returns the index of the file if successful, 0 if it fails. Any I/O Error is also returned if it occurs.

Trait Implementations§

source§

impl Debug for ModuleFile

source§

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

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

impl Default for ModuleFile

source§

fn default() -> ModuleFile

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