AsBusDevice

Trait AsBusDevice 

Source
pub unsafe trait AsBusDevice<Ctx: DeviceContext>: AsRef<Device<Ctx>> {
    const OFFSET: usize;

    // Provided method
    unsafe fn from_device(dev: &Device<Ctx>) -> &Self
       where Self: Sized { ... }
}
Expand description

Convert device references to bus device references.

Bus devices can implement this trait to allow abstractions to provide the bus device in class device callbacks.

This must not be used by drivers and is intended for bus and class device abstractions only.

§Safety

AsBusDevice::OFFSET must be the offset of the embedded base struct device field within a bus device structure.

Required Associated Constants§

Source

const OFFSET: usize

The relative offset to the device field.

Use offset_of!(bindings, field) macro to avoid breakage.

Provided Methods§

Source

unsafe fn from_device(dev: &Device<Ctx>) -> &Self
where Self: Sized,

Convert a reference to Device into Self.

§Safety

dev must be contained in Self.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Ctx: DeviceContext> AsBusDevice<Ctx> for kernel::auxiliary::Device<Ctx>

Source§

const OFFSET: usize = 0usize

Source§

impl<Ctx: DeviceContext> AsBusDevice<Ctx> for I2cClient<Ctx>

Source§

const OFFSET: usize = 32usize

Source§

impl<Ctx: DeviceContext> AsBusDevice<Ctx> for kernel::pci::Device<Ctx>

Source§

const OFFSET: usize = 200usize

Source§

impl<Ctx: DeviceContext> AsBusDevice<Ctx> for kernel::platform::Device<Ctx>

Source§

const OFFSET: usize = 16usize

Source§

impl<Ctx: DeviceContext> AsBusDevice<Ctx> for Interface<Ctx>

Source§

const OFFSET: usize = 128usize