pub trait Param {
type State: Send;
type Item<'w>;
// Required methods
fn init(registry: &Registry) -> Self::State;
unsafe fn fetch<'w>(
world: &'w World,
state: &'w mut Self::State,
) -> Self::Item<'w>;
// Provided method
fn resource_id(state: &Self::State) -> Option<ResourceId> { ... }
}Expand description
Trait for types that can be resolved from a Registry at build time
and fetched from World at dispatch time.
Analogous to Bevy’s SystemParam.
Two-phase resolution:
- Build time —
initresolves opaque state (e.g. aResourceId) from the registry. This panics if the required type isn’t registered — giving an early build-time error. - Dispatch time —
fetchuses the cached state to produce a reference via a single pointer deref — zero framework overhead.
§Built-in impls
| Param | State | Description |
|---|---|---|
Res<T> | ResourceId | Shared read |
ResMut<T> | ResourceId | Exclusive write |
Option<Res<T>> | Option<ResourceId> | Optional shared read |
Option<ResMut<T>> | Option<ResourceId> | Optional exclusive write |
Local<T> | T | Per-handler state (not in World) |
RegistryRef | () | Read-only registry access |
() | () | Event-only handlers |
| Tuples of params | Tuple of states | Up to 8 params |
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn resource_id(state: &Self::State) -> Option<ResourceId>
fn resource_id(state: &Self::State) -> Option<ResourceId>
The ResourceId this param accesses, if any.
Returns None for params that don’t access World resources
(e.g. Local<T>). Used by Registry::check_access to enforce
one borrow per resource per handler.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.