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§

source

const DRIVER_DATA_OFFSET: usize

The offset (in bytes) to the context/data field in the raw device ID.

Required Methods§

source

fn index(&self) -> usize

The index stored at DRIVER_DATA_OFFSET of the implementor of the RawDeviceIdIndex trait.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl RawDeviceIdIndex for kernel::acpi::DeviceId

source§

impl RawDeviceIdIndex for kernel::auxiliary::DeviceId

source§

impl RawDeviceIdIndex for kernel::of::DeviceId

source§

impl RawDeviceIdIndex for kernel::pci::DeviceId