pub trait Driver {
type IdInfo: 'static;
type Data<'bound>: Send + 'bound;
const ID_TABLE: IdTable<Self::IdInfo>;
// Required methods
fn probe<'bound>(
interface: &'bound Interface<Core<'_>>,
id: &DeviceId,
id_info: &'bound Self::IdInfo,
) -> impl PinInit<Self::Data<'bound>, Error> + 'bound;
fn disconnect<'bound>(
interface: &'bound Interface<Core<'_>>,
data: Pin<&Self::Data<'bound>>,
);
}Expand description
The USB driver trait.
§Examples
use kernel::prelude::*;
struct MyDriver;
kernel::usb_device_table!(
USB_TABLE,
MODULE_USB_TABLE,
<MyDriver as usb::Driver>::IdInfo,
[
(usb::DeviceId::from_id(0x1234, 0x5678), ()),
(usb::DeviceId::from_id(0xabcd, 0xef01), ()),
]
);
impl usb::Driver for MyDriver {
type IdInfo = ();
type Data<'bound> = Self;
const ID_TABLE: usb::IdTable<Self::IdInfo> = &USB_TABLE;
fn probe<'bound>(
_interface: &'bound usb::Interface<Core<'_>>,
_id: &usb::DeviceId,
_info: &'bound Self::IdInfo,
) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
Err(ENODEV)
}
fn disconnect<'bound>(
_interface: &'bound usb::Interface<Core<'_>>,
_data: Pin<&Self::Data<'bound>>,
) {
}
}Required Associated Constants§
Required Associated Types§
Required Methods§
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.