wh40kdc
The Warhammer 40K dataset for the
40kdc-data schema
layer — the canonical community schema for 40K game entities. This crate is the
Rust counterpart of the @alpaca-software/40kdc-data npm package: it ships the
generated entity types, the whole dataset embedded behind a linked, typed
API, and a ListForge army-list importer.
Every type is generated from the project's JSON Schemas (JSON Schema draft
2020-12) via typify, so the Rust structs
stay in lockstep with the schemas that other consortium tools validate against.
Data API (the headline)
With the default features, the entire dataset is embedded at build time behind a
linked accessor. Find an entity and follow it to its faction, weapons, abilities,
and the phases each ability acts in. Lookup is diacritic- and
punctuation-insensitive, so "Kharn" resolves "Khârn the Betrayer":
use ;
let ds = embedded;
let kharn = ds.find_unit.unwrap;
let shooting: = ds
.abilities_of
.into_iter
.filter
.map
.collect;
assert_eq!;
assert_eq!;
An ability's phases are not stored on the ability — they come from
phase-mappings, joined for you by [Dataset::phases_of]. Name matching is shared
with the npm package via the exported [normalize_name] (NFD diacritic strip,
casefold, quote/whitespace normalization).
Army-list importer
The import feature turns a ListForge "share" export (URL, base64 segment, or
raw JSON) into a resolved 40kdc Roster, keyed on entity ids and validatable
against roster.schema.json. It reads only an allowlist of structural fields, so
it never carries reproduced rules text into its output.
use Dataset;
use import_listforge;
let roster = import_listforge.unwrap;
println!;
The importer is multi-format by design: decode and resolve are written once,
and each source format (ListForge today; New Recruit, Rosterizer, … next) is a
small FormatAdapter that lowers a payload to the shared ParsedRoster.
Types-only usage
To consume just the generated types (no embedded data, no extra dependencies), disable default features:
[]
= { = "0.2", = false }
= "1"
use ;
let units: = from_str?;
let weapons: = from_str?;
The bundled schema is available as a string for downstream validation:
let schema: Value = from_str?;
Cargo features
bundled-data(default) — the embedded dataset and the linked data API (Dataset,Collection,normalize_name).import(default) — the army-list importer (impliesbundled-data).
Disable both with default-features = false for a types-only build.
Regenerating
Two artifacts are checked in. To regenerate after a change:
&&
CI fails if the committed artifacts drift from the schemas or the data.
Licensing
- The crate code is MIT.
- The schema content these types describe is CC0 (public domain).
- The embedded dataset mixes two licenses: the structural core data is CC0,
and the community-authored enrichment data (abilities, phase-mappings, and the
ability mechanics they encode) is CC BY 4.0.
If you redistribute the embedded data (e.g. by depending on this crate with the
default
bundled-datafeature), attribute the 40kdc community (Tabletop Developer Consortium). The types-only build (default-features = false) carries no data and so no attribution obligation.
This dataset is community-created and mirrors Games Workshop's datasheet structure. Stat lines and points are numerical facts; no rules text or ability prose is reproduced.