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>
impl<TSource: Read + Seek> Modpkg<TSource>
Sourcepub fn load_metadata(&mut self) -> Result<ModpkgMetadata, ModpkgError>
pub fn load_metadata(&mut self) -> Result<ModpkgMetadata, ModpkgError>
Load the metadata chunk from the mod package.
Source§impl<TSource: Read + Seek> Modpkg<TSource>
impl<TSource: Read + Seek> Modpkg<TSource>
pub fn mount_from_reader(source: TSource) -> Result<Self, ModpkgError>
Source§impl<TSource: Read + Seek> Modpkg<TSource>
impl<TSource: Read + Seek> Modpkg<TSource>
Sourcepub fn load_readme(&mut self) -> Result<Vec<u8>, ModpkgError>
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>
impl<TSource: Read + Seek> Modpkg<TSource>
Sourcepub fn load_thumbnail(&mut self) -> Result<Vec<u8>, ModpkgError>
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>
impl<TSource: Read + Seek> Modpkg<TSource>
Sourcepub fn decoder(&mut self) -> ModpkgDecoder<'_, TSource>
pub fn decoder(&mut self) -> ModpkgDecoder<'_, TSource>
Create a decoder for this modpkg
Sourcepub fn load_chunk_raw(
&mut self,
path_hash: u64,
layer_hash: u64,
) -> Result<Box<[u8]>, ModpkgError>
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
Sourcepub fn load_chunk_decompressed_by_hash(
&mut self,
path_hash: u64,
layer_hash: u64,
) -> Result<Box<[u8]>, ModpkgError>
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
Sourcepub fn load_chunk_raw_by_path(
&mut self,
path: &str,
layer: Option<&str>,
) -> Result<Box<[u8]>, ModpkgError>
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
Sourcepub fn load_chunk_decompressed_by_path(
&mut self,
path: &str,
layer: Option<&str>,
) -> Result<Box<[u8]>, ModpkgError>
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
Sourcepub fn get_chunk(
&self,
path: &str,
layer: Option<&str>,
) -> Result<&ModpkgChunk, ModpkgError>
pub fn get_chunk( &self, path: &str, layer: Option<&str>, ) -> Result<&ModpkgChunk, ModpkgError>
Get a chunk by path and layer name
Sourcepub fn load_chunk_decompressed(
&mut self,
chunk: &ModpkgChunk,
) -> Result<Box<[u8]>, ModpkgError>
pub fn load_chunk_decompressed( &mut self, chunk: &ModpkgChunk, ) -> Result<Box<[u8]>, ModpkgError>
Load a chunk into memory
Sourcepub fn has_chunk(&self, path: &str, layer: Option<&str>) -> bool
pub fn has_chunk(&self, path: &str, layer: Option<&str>) -> bool
Check if a chunk exists by path and layer name
Sourcepub fn layer_index(&self, layer: &str) -> Option<u32>
pub fn layer_index(&self, layer: &str) -> Option<u32>
Resolve a layer name to its index in the layer table.
Sourcepub fn wad_index(&self, wad_name: &str) -> Option<u32>
pub fn wad_index(&self, wad_name: &str) -> Option<u32>
Resolve a WAD name to its index in the WAD table.
Sourcepub fn wad_name_for_index(&self, wad_index: u32) -> Option<&str>
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.
Sourcepub fn chunks_for_wad_layer(
&self,
wad_index: u32,
layer_index: u32,
) -> &[(u64, u64)]
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.
Sourcepub fn load_chunks_batch(
&mut self,
keys: &[(u64, u64)],
) -> Result<Vec<BatchChunkEntry>, ModpkgError>
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.