Skip to main content

Driver

Trait Driver 

Source
pub trait Driver {
    type IdInfo: 'static;
    type Data<'bound>: Send + 'bound;

    const ID_TABLE: IdTable<Self::IdInfo>;

    // Required method
    fn probe<'bound>(
        dev: &'bound Device<Core<'_>>,
        id_info: &'bound Self::IdInfo,
    ) -> impl PinInit<Self::Data<'bound>, Error> + 'bound;

    // Provided method
    fn unbind<'bound>(
        dev: &'bound Device<Core<'_>>,
        this: Pin<&Self::Data<'bound>>,
    ) { ... }
}
Expand description

The auxiliary driver trait.

Drivers must implement this trait in order to get an auxiliary driver registered.

Required Associated Constants§

Source

const ID_TABLE: IdTable<Self::IdInfo>

The table of device ids supported by the driver.

Required Associated Types§

Source

type IdInfo: 'static

The type holding information about each device id supported by the driver.

TODO: Use associated_type_defaults once stabilized:

type IdInfo: ’static = ();

Source

type Data<'bound>: Send + 'bound

The type of the driver’s bus device private data.

Required Methods§

Source

fn probe<'bound>( dev: &'bound Device<Core<'_>>, id_info: &'bound Self::IdInfo, ) -> impl PinInit<Self::Data<'bound>, Error> + 'bound

Auxiliary driver probe.

Called when an auxiliary device is matches a corresponding driver.

Provided Methods§

Source

fn unbind<'bound>(dev: &'bound Device<Core<'_>>, this: Pin<&Self::Data<'bound>>)

Auxiliary driver unbind.

Called when a Device is unbound from its bound Driver. Implementing this callback is optional.

This callback serves as a place for drivers to perform teardown operations that require a &Device<Core> or &Device<Bound> reference. For instance, drivers may try to perform I/O operations to gracefully tear down the device.

Otherwise, release operations for driver resources should be performed in Drop.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§