pub struct PackLoader;Expand description
Stateless loader for Waymark content packs.
All methods are associated functions (no &self) — create no instance, just call
PackLoader::load_pack_config(json), etc.
Implementations§
Source§impl PackLoader
impl PackLoader
Sourcepub fn detect_version(json: &Value) -> SchemaVersion
pub fn detect_version(json: &Value) -> SchemaVersion
Detect schema version from raw JSON value.
Looks for schema_version at the top level. If absent, returns Legacy.
If present and equal to "dreamwell_waymark_v1.0.0", returns V1_0_0.
Otherwise returns Unknown(value).
Sourcepub fn load_pack_config(json: &str) -> Result<DreamwellPackV1, PackError>
pub fn load_pack_config(json: &str) -> Result<DreamwellPackV1, PackError>
Load a pack configuration from a JSON string.
Detects schema version and deserializes into DreamwellPackV1. Legacy packs
(without schema_version) are loaded directly since DreamwellPackV1 uses
serde(default) on all optional fields.
Sourcepub fn validate_pack(pack: &DreamwellPackV1) -> PackValidationResult
pub fn validate_pack(pack: &DreamwellPackV1) -> PackValidationResult
Validate a loaded pack configuration. Returns errors and warnings.
Sourcepub fn load_items(json: &str) -> Result<ItemsFile, PackError>
pub fn load_items(json: &str) -> Result<ItemsFile, PackError>
Load and parse an items file from JSON.
Sourcepub fn load_enemies(json: &str) -> Result<EnemiesFile, PackError>
pub fn load_enemies(json: &str) -> Result<EnemiesFile, PackError>
Load and parse an enemies file from JSON.
Sourcepub fn load_abilities(json: &str) -> Result<AbilitiesFile, PackError>
pub fn load_abilities(json: &str) -> Result<AbilitiesFile, PackError>
Load and parse an abilities file from JSON.
Sourcepub fn load_loot_tables(json: &str) -> Result<LootTablesFile, PackError>
pub fn load_loot_tables(json: &str) -> Result<LootTablesFile, PackError>
Load and parse a loot tables file from JSON.
Supports both the array format ("tables": [...]) and the object format
("loot_tables": { "id": { ... } }). When the object format is detected,
entries are normalized into the tables vec.
Sourcepub fn load_economy(json: &str) -> Result<EconomyFile, PackError>
pub fn load_economy(json: &str) -> Result<EconomyFile, PackError>
Load and parse an economy file from JSON.
Sourcepub fn load_stats(json: &str) -> Result<StatsFile, PackError>
pub fn load_stats(json: &str) -> Result<StatsFile, PackError>
Load and parse a stats file from JSON.
Sourcepub fn validate_content_refs(
items: &ItemsFile,
enemies: &EnemiesFile,
abilities: &AbilitiesFile,
loot_tables: &LootTablesFile,
) -> Vec<PackWarning>
pub fn validate_content_refs( items: &ItemsFile, enemies: &EnemiesFile, abilities: &AbilitiesFile, loot_tables: &LootTablesFile, ) -> Vec<PackWarning>
Validate content cross-references across multiple content files.
Checks:
- Loot table
item_idreferences exist in items. - Enemy
loot_tablereferences exist in loot tables. - Enemy
abilitiesreferences exist in abilities. - Enemy
innate_abilityreferences exist in abilities. - Loot entry weights are positive.
- Item IDs are unique.
- Enemy IDs are unique.
- Ability IDs are unique.
- Loot table IDs are unique.
Sourcepub fn validate_props(props: &[PropDefinition]) -> Vec<PackWarning>
pub fn validate_props(props: &[PropDefinition]) -> Vec<PackWarning>
Validate all prop definitions in a pack.
Checks:
idis valid (non-empty, lowercase alphanumeric + underscore).- No duplicate
idvalues. default_statereferences an existing state key.- State
on_interactandon_secondary_interactreference valid state keys (warning). - Props with
has_secondary_statehave states defined.