pub trait Driver {
type IdInfo: 'static;
const ID_TABLE: IdTable<Self::IdInfo>;
// Required methods
fn probe(
interface: &Interface<Core>,
id: &DeviceId,
id_info: &Self::IdInfo,
) -> Result<Pin<KBox<Self>>>;
fn disconnect(interface: &Interface<Core>, data: Pin<&Self>);
}
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 = ();
const ID_TABLE: usb::IdTable<Self::IdInfo> = &USB_TABLE;
fn probe(
_interface: &usb::Interface<Core>,
_id: &usb::DeviceId,
_info: &Self::IdInfo,
) -> Result<Pin<KBox<Self>>> {
Err(ENODEV)
}
fn disconnect(_interface: &usb::Interface<Core>, _data: Pin<&Self>) {}
}
Required Associated Constants§
Required Associated Types§
Required Methods§
Sourcefn probe(
interface: &Interface<Core>,
id: &DeviceId,
id_info: &Self::IdInfo,
) -> Result<Pin<KBox<Self>>>
fn probe( interface: &Interface<Core>, id: &DeviceId, id_info: &Self::IdInfo, ) -> Result<Pin<KBox<Self>>>
USB driver probe.
Called when a new USB interface is bound to this driver. Implementers should attempt to initialize the interface here.
Sourcefn disconnect(interface: &Interface<Core>, data: Pin<&Self>)
fn disconnect(interface: &Interface<Core>, data: Pin<&Self>)
USB driver disconnect.
Called when the USB interface is about to be unbound from this driver.
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.