Trait kernel::device_id::RawDeviceIdIndex
source · pub unsafe trait RawDeviceIdIndex: RawDeviceId {
const DRIVER_DATA_OFFSET: usize;
// Required method
fn index(&self) -> usize;
}
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.
Required Methods§
sourcefn index(&self) -> usize
fn index(&self) -> usize
The index stored at DRIVER_DATA_OFFSET
of the implementor of the RawDeviceIdIndex
trait.