pub unsafe trait RawDeviceIdIndex: RawDeviceId {
const DRIVER_DATA_OFFSET: usize;
// Provided methods
unsafe fn info_unchecked<U>(&self) -> &'static U { ... }
unsafe fn info_unchecked_opt<U>(&self) -> Option<&'static U> { ... }
}Expand description
Extension trait for RawDeviceId for devices that embed an index or context value.
This is typically used when the device ID struct includes a field like driver_data
that is used to store a pointer-sized value (e.g., an index or context pointer).
§Safety
Implementers must ensure that DRIVER_DATA_OFFSET is the correct offset (in bytes) to
the context/data field (e.g., the driver_data field) within the raw device ID structure.
This field must be correctly sized to hold a usize.
Ideally, the data should be added during Self to RawType conversion,
but there’s currently no way to do it when using traits in const.
Required Associated Constants§
Sourceconst DRIVER_DATA_OFFSET: usize
const DRIVER_DATA_OFFSET: usize
The offset (in bytes) to the context/data field in the raw device ID.
Provided Methods§
Sourceunsafe fn info_unchecked<U>(&self) -> &'static U
unsafe fn info_unchecked<U>(&self) -> &'static U
Obtain the data pointer stored inside the device ID.
§Safety
&Self must be stored inside a IdArray<Self, U>.
Sourceunsafe fn info_unchecked_opt<U>(&self) -> Option<&'static U>
unsafe fn info_unchecked_opt<U>(&self) -> Option<&'static U>
Obtain the data pointer stored inside the device ID.
§Safety
&Self must be stored inside a IdArray<Self, U>, or has NULL (or 0) as driver data.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".