Skip to main content

SystemParam

Trait SystemParam 

Source
pub unsafe trait SystemParam<R> {
    type Item<'resources>;

    const ACCESS: ResourceAccess;

    // Required method
    unsafe fn fetch<'resources>(
        resources: *mut R,
    ) -> Result<Self::Item<'resources>, FetchError>;
}
Expand description

Extracts one typed argument from a resource container.

Most commands use Res and ResMut, which implement this trait through ResourceProvider. Manual implementations support fallible maps, guards, handles, and application-specific parameter types.

§Safety

An implementation must uphold all of these requirements:

  • every returned value is valid only for Item<'resources> and does not outlive the pointed-to container;
  • returned values access only the logical resource declared by ACCESS;
  • implementations that may touch overlapping memory use the same ResourceId;
  • shared access never permits unsound mutation, while exclusive access may produce unique mutable references;
  • fetch does not move or invalidate the resource container.

Required Associated Constants§

Source

const ACCESS: ResourceAccess

Memory access performed by this parameter.

Required Associated Types§

Source

type Item<'resources>

Argument passed to the command for one resource-container lifetime.

Required Methods§

Source

unsafe fn fetch<'resources>( resources: *mut R, ) -> Result<Self::Item<'resources>, FetchError>

Extracts the command argument from resources.

§Safety

resources must be non-null, properly aligned, and point to a valid R exclusively borrowed for 'resources. The caller must validate this access against every other live parameter before calling fetch.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'param, R, T, Tag> SystemParam<R> for Res<'param, T, Tag>
where R: ResourceProvider<T, Tag>, T: 'static, Tag: 'static,

Source§

const ACCESS: ResourceAccess

Source§

type Item<'resources> = Res<'resources, T, Tag>

Source§

impl<'param, R, T, Tag> SystemParam<R> for ResMut<'param, T, Tag>
where R: ResourceProvider<T, Tag>, T: 'static, Tag: 'static,

Source§

const ACCESS: ResourceAccess

Source§

type Item<'resources> = ResMut<'resources, T, Tag>