Skip to main content

PackLoader

Struct PackLoader 

Source
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

Source

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).

Source

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.

Source

pub fn validate_pack(pack: &DreamwellPackV1) -> PackValidationResult

Validate a loaded pack configuration. Returns errors and warnings.

Source

pub fn load_items(json: &str) -> Result<ItemsFile, PackError>

Load and parse an items file from JSON.

Source

pub fn load_enemies(json: &str) -> Result<EnemiesFile, PackError>

Load and parse an enemies file from JSON.

Source

pub fn load_abilities(json: &str) -> Result<AbilitiesFile, PackError>

Load and parse an abilities file from JSON.

Source

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.

Source

pub fn load_economy(json: &str) -> Result<EconomyFile, PackError>

Load and parse an economy file from JSON.

Source

pub fn load_stats(json: &str) -> Result<StatsFile, PackError>

Load and parse a stats file from JSON.

Source

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_id references exist in items.
  • Enemy loot_table references exist in loot tables.
  • Enemy abilities references exist in abilities.
  • Enemy innate_ability references 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.
Source

pub fn validate_props(props: &[PropDefinition]) -> Vec<PackWarning>

Validate all prop definitions in a pack.

Checks:

  • id is valid (non-empty, lowercase alphanumeric + underscore).
  • No duplicate id values.
  • default_state references an existing state key.
  • State on_interact and on_secondary_interact reference valid state keys (warning).
  • Props with has_secondary_state have states defined.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.