Trait WorldgenHost
pub trait WorldgenHost {
// Required methods
fn registry(&self, name: &str) -> Option<Arc<[String]>>;
fn setting(&self, mod_id: &str, key: &str) -> Option<String>;
fn mods(&self) -> LoadedMods;
}Expand description
The view of a hook fired while a feature generates, where no game is at hand: on a worldgen worker thread, or on the server thread when a sapling grows. It carries the server’s registries, its settings and the mod list; the server builds it once per resource generation, a hook never builds one, and its answers never change while it is held. There are no writes, no level or entity handles and no transaction: what the generating region holds is the hook’s own arguments.
use mod_api::{Host, WorldgenHost};
fn game(_: &dyn Host) {}
fn generate(host: &dyn WorldgenHost) { game(host); }use mod_api::{HostTransaction, WorldgenHost};
fn generate(host: &mut dyn WorldgenHost) {
let _: Result<(), ()> = host.transaction(|_, _| Ok(()));
}Required Methods§
fn registry(&self, name: &str) -> Option<Arc<[String]>>
fn registry(&self, name: &str) -> Option<Arc<[String]>>
Registry names in ID order, from the server’s resource generation.
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 when the server built this view, without file I/O.
fn mods(&self) -> LoadedMods
fn mods(&self) -> LoadedMods
The same loaded-mod view available during registration.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".