ltk_modpkg
A Rust library for reading, writing, and packing .modpkg archives — the binary mod distribution format for League of Legends mods in the League Mod Toolkit.
Overview
A .modpkg file is a binary container that stores mod content organized by layers and WAD targets, with per-chunk zstd compression, xxhash checksums, and embedded metadata (name, version, authors, license, thumbnail, etc.).
This crate provides:
- Reading — mount a modpkg from any
Read + Seeksource and access chunks by path hash - Writing — build a modpkg from scratch using
ModpkgBuilder - Project packing — scan a mod project directory and produce a modpkg in one call (requires
projectfeature) - Extraction — extract modpkg contents back to disk
- Metadata — read/write msgpack-encoded mod metadata
Usage
Reading a modpkg
use Modpkg;
use File;
let file = open?;
let mut modpkg = mount_from_reader?;
// Read metadata
let metadata = modpkg.load_metadata?;
println!;
// List WADs
for wad_name in modpkg.wads.values
Packing a mod project (requires project feature)
use ProjectPacker;
use Utf8PathBuf;
// Loads mod.config.json/toml automatically from the project directory
let packer = new?;
packer.pack?;
Or pack to an in-memory buffer:
use ProjectPacker;
use Utf8PathBuf;
let mut buffer = new;
new?
.pack_to_writer?;
Building a modpkg programmatically
use ;
use ModpkgCompression;
let builder = default
.with_layer
.with_chunk;
let mut output = create?;
builder.build_to_writer?;
Features
| Feature | Default | Description |
|---|---|---|
project |
no | Enables ProjectPacker and mod project packing from disk. Adds ltk_mod_project dependency. |
Project structure
The expected mod project layout (used by ProjectPacker):
my-mod/
├── mod.config.json # or mod.config.toml
├── README.md # optional, embedded in modpkg
├── thumbnail.webp # optional, embedded in modpkg
├── content/
│ ├── base/ # base layer (priority 0)
│ │ ├── Graves.wad.client/ # WAD target directory
│ │ │ ├── data/
│ │ │ └── assets/
│ │ └── Map11.wad.client/
│ │ └── data/
│ └── high-res/ # additional layer
│ └── Graves.wad.client/
│ └── assets/
└── build/ # output directory
License
MIT OR Apache-2.0