Trait DataLoadContext
pub trait DataLoadContext {
// Required methods
fn origin(&self) -> DataLoadOrigin;
fn registry(&self, name: &str) -> Option<Arc<[String]>>;
fn fluid_key(&self, id: &str) -> Option<FluidKey>;
fn setting(&self, mod_id: &str, key: &str) -> Option<String>;
fn mods(&self) -> LoadedMods;
// Provided method
fn fluid_tags(&self) -> Option<Arc<[(String, Arc<[String]>)]>> { ... }
}Expand description
A data load’s read-only view. The owning loader supplies its origin and metadata; reading already-loaded data never creates this context.
use mod_api::{DataLoadContext, Host};
fn game(_: &dyn Host) {}
fn load(context: &dyn DataLoadContext) { game(context); }use mod_api::{prelude::EntitiesHost, DataLoadContext};
fn load(context: &dyn DataLoadContext) { let _ = EntitiesHost::entity(context, 1); }use mod_api::{DataLoadContext, HostTransaction};
fn load(context: &mut dyn DataLoadContext) {
let _: Result<(), ()> = context.transaction(|_, _| Ok(()));
}Required Methods§
fn origin(&self) -> DataLoadOrigin
fn origin(&self) -> DataLoadOrigin
The phase selected at the owning load boundary.
fn registry(&self, name: &str) -> Option<Arc<[String]>>
fn registry(&self, name: &str) -> Option<Arc<[String]>>
Registry names in ID order, from this resource generation’s snapshot.
fn fluid_key(&self, id: &str) -> Option<FluidKey>
fn fluid_key(&self, id: &str) -> Option<FluidKey>
Resolve a fluid name against this load’s registered fluid identities.
fn setting(&self, mod_id: &str, key: &str) -> Option<String>
fn setting(&self, mod_id: &str, key: &str) -> Option<String>
A loaded mod’s setting captured at the owning load boundary, without file I/O.
fn mods(&self) -> LoadedMods
fn mods(&self) -> LoadedMods
The same loaded-mod view available during registration.
Provided Methods§
The fluid tags this load’s resources hold (data/<ns>/tags/fluid):
each tag id to the fluids it names, in the sources’ order — what a
recipe’s fluid ingredient resolves its #tags with. None where the
load reads no recipe resources.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".