pub trait OptimizableContainer: Container {
// Required method
fn optimize(
&mut self,
paths_to_optimize: Option<Vec<ContainerPath>>,
dependencies: &mut Dependencies,
schema: &Schema,
game: &GameInfo,
options: &OptimizerOptions,
) -> Result<(HashSet<String>, HashSet<String>)>;
}Expand description
Trait for containers (like Pack) that can optimize their contents.
This trait provides pack-wide optimization capabilities, processing multiple files and handling deletions.
Required Methods§
Sourcefn optimize(
&mut self,
paths_to_optimize: Option<Vec<ContainerPath>>,
dependencies: &mut Dependencies,
schema: &Schema,
game: &GameInfo,
options: &OptimizerOptions,
) -> Result<(HashSet<String>, HashSet<String>)>
fn optimize( &mut self, paths_to_optimize: Option<Vec<ContainerPath>>, dependencies: &mut Dependencies, schema: &Schema, game: &GameInfo, options: &OptimizerOptions, ) -> Result<(HashSet<String>, HashSet<String>)>
Optimizes the container’s contents.
§Arguments
paths_to_optimize- Specific paths to optimize, orNonefor all filesdependencies- Dependencies cache for vanilla data comparisonschema- Schema for decoding tablesgame- Game information for format-specific handlingoptions- Configuration controlling which optimizations to apply
§Returns
A tuple of (deleted_files, optimized_files) containing the paths of
files that were deleted and files that were modified.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl OptimizableContainer for Pack
impl OptimizableContainer for Pack
Source§fn optimize(
&mut self,
paths_to_optimize: Option<Vec<ContainerPath>>,
dependencies: &mut Dependencies,
schema: &Schema,
game: &GameInfo,
options: &OptimizerOptions,
) -> Result<(HashSet<String>, HashSet<String>)>
fn optimize( &mut self, paths_to_optimize: Option<Vec<ContainerPath>>, dependencies: &mut Dependencies, schema: &Schema, game: &GameInfo, options: &OptimizerOptions, ) -> Result<(HashSet<String>, HashSet<String>)>
This function optimizes the provided Pack file in order to make it smaller and more compatible.
Specifically, it performs the following optimizations:
- DB/Loc tables (except if the table has the same name as his vanilla/parent counterpart and
optimize_datacored_tablesis false):- Removal of duplicated entries.
- Removal of ITM (Identical To Master) entries.
- Removal of ITNR (Identical To New Row) entries.
- Removal of empty tables.
- Conversion of datacores into twad_key_deletes_entries.
- Text files:
- Removal of XML files in map folders (extra files resulting of Terry export process).
- Removal of XML files in prefabs folder (extra files resulting of Terry export process).
- Removal of .agf files (byproduct of bob exporting models).
- Removal of .model_statistics files (byproduct of bob exporting models).
- Portrait Settings files:
- Removal of variants not present in the variants table (unused data).
- Removal of art sets not present in the campaign_character_arts table (unused data).
- Removal of empty masks.
- Removal of empty Portrait Settings files.
- Pack:
- Remove files identical to parent/vanilla.
- Remove case-insensitively duplicated files with identical contents.
- Apply the most modern compression format the active game supports, so the next save compresses the files.