pub unsafe trait ResourceProvider<T: ?Sized + 'static, Tag: 'static = DefaultResourceTag> {
const ID: ResourceId;
// Required method
unsafe fn get(resources: *mut Self) -> *mut T;
}Expand description
Provides one typed resource from an application-owned container.
Tag distinguishes multiple fields with the same T. Applications should
normally use crate::resources!, which generates these implementations
together with the resource container.
§Safety
Every implementation that may return overlapping memory must use the same
ID. A non-null, aligned pointer returned by get must point to a live T
inside Self, remain valid while the container is exclusively borrowed,
and must not be used to move the container field. Null or misaligned
pointers are reported as crate::FetchError::InvalidPointer.
Required Associated Constants§
Sourceconst ID: ResourceId
const ID: ResourceId
Identity used to detect overlapping shared and exclusive access.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".