Skip to main content

Modpkg

Struct Modpkg 

Source
pub struct Modpkg<TSource: Read + Seek> {
    pub layer_indices: Vec<u64>,
    pub layers: HashMap<u64, ModpkgLayer>,
    pub chunk_path_indices: Vec<u64>,
    pub chunk_paths: HashMap<u64, String>,
    pub wads_indices: Vec<u64>,
    pub wads: HashMap<u64, String>,
    pub chunks: HashMap<(u64, u64), ModpkgChunk>,
    pub chunks_by_wad_layer: HashMap<(u32, u32), Vec<(u64, u64)>>,
    /* private fields */
}

Fields§

§layer_indices: Vec<u64>§layers: HashMap<u64, ModpkgLayer>§chunk_path_indices: Vec<u64>§chunk_paths: HashMap<u64, String>§wads_indices: Vec<u64>§wads: HashMap<u64, String>§chunks: HashMap<(u64, u64), ModpkgChunk>

The chunks in the mod package.

The key is a tuple of the path hash and the layer hash respectively.

§chunks_by_wad_layer: HashMap<(u32, u32), Vec<(u64, u64)>>

Secondary index: chunks grouped by (wad_index, layer_index).

Values are chunk keys (path_hash, layer_hash) that can be looked up in chunks.

Implementations§

Source§

impl<TSource: Read + Seek> Modpkg<TSource>

Source

pub fn load_metadata(&mut self) -> Result<ModpkgMetadata, ModpkgError>

Load the metadata chunk from the mod package.

Source§

impl<TSource: Read + Seek> Modpkg<TSource>

Source

pub fn mount_from_reader(source: TSource) -> Result<Self, ModpkgError>

Source§

impl<TSource: Read + Seek> Modpkg<TSource>

Source

pub fn load_readme(&mut self) -> Result<Vec<u8>, ModpkgError>

Load the README.md chunk from the mod package.

Source§

impl<TSource: Read + Seek> Modpkg<TSource>

Source

pub fn load_thumbnail(&mut self) -> Result<Vec<u8>, ModpkgError>

Load the thumbnail chunk from the mod package.

Source§

impl<TSource: Read + Seek> Modpkg<TSource>

Source

pub fn decoder(&mut self) -> ModpkgDecoder<'_, TSource>

Create a decoder for this modpkg

Source

pub fn load_chunk_raw( &mut self, path_hash: u64, layer_hash: u64, ) -> Result<Box<[u8]>, ModpkgError>

Load the raw data of a chunk using the path hash and layer hash

Source

pub fn load_chunk_decompressed_by_hash( &mut self, path_hash: u64, layer_hash: u64, ) -> Result<Box<[u8]>, ModpkgError>

Load and decompress the data of a chunk using the path hash and layer hash

Source

pub fn load_chunk_raw_by_path( &mut self, path: &str, layer: Option<&str>, ) -> Result<Box<[u8]>, ModpkgError>

Load the raw data of a chunk by path and layer name

Source

pub fn load_chunk_decompressed_by_path( &mut self, path: &str, layer: Option<&str>, ) -> Result<Box<[u8]>, ModpkgError>

Load and decompress the data of a chunk by path and layer name

Source

pub fn get_chunk( &self, path: &str, layer: Option<&str>, ) -> Result<&ModpkgChunk, ModpkgError>

Get a chunk by path and layer name

Source

pub fn load_chunk_decompressed( &mut self, chunk: &ModpkgChunk, ) -> Result<Box<[u8]>, ModpkgError>

Load a chunk into memory

Source

pub fn has_chunk(&self, path: &str, layer: Option<&str>) -> bool

Check if a chunk exists by path and layer name

Source

pub fn layer_index(&self, layer: &str) -> Option<u32>

Resolve a layer name to its index in the layer table.

Source

pub fn wad_index(&self, wad_name: &str) -> Option<u32>

Resolve a WAD name to its index in the WAD table.

Source

pub fn wad_name_for_index(&self, wad_index: u32) -> Option<&str>

Get the WAD name for a given WAD index, or None if the index is invalid.

Source

pub fn chunks_for_wad_layer( &self, wad_index: u32, layer_index: u32, ) -> &[(u64, u64)]

Get the chunk keys for a given (wad_index, layer_index) pair.

Returns an empty slice if no chunks match.

Source

pub fn load_chunks_batch( &mut self, keys: &[(u64, u64)], ) -> Result<Vec<BatchChunkEntry>, ModpkgError>

Load and decompress multiple chunks in offset-sorted order for better I/O performance.

Returns (path_hash, layer_hash, data) tuples in arbitrary order.

Trait Implementations§

Source§

impl<TSource: Debug + Read + Seek> Debug for Modpkg<TSource>

Source§

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

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

impl<TSource: PartialEq + Read + Seek> PartialEq for Modpkg<TSource>

Source§

fn eq(&self, other: &Modpkg<TSource>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<TSource: Read + Seek> StructuralPartialEq for Modpkg<TSource>

Auto Trait Implementations§

§

impl<TSource> Freeze for Modpkg<TSource>
where TSource: Freeze,

§

impl<TSource> RefUnwindSafe for Modpkg<TSource>
where TSource: RefUnwindSafe,

§

impl<TSource> Send for Modpkg<TSource>
where TSource: Send,

§

impl<TSource> Sync for Modpkg<TSource>
where TSource: Sync,

§

impl<TSource> Unpin for Modpkg<TSource>
where TSource: Unpin,

§

impl<TSource> UnsafeUnpin for Modpkg<TSource>
where TSource: UnsafeUnpin,

§

impl<TSource> UnwindSafe for Modpkg<TSource>
where TSource: UnwindSafe,

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.