pub struct Context { /* private fields */ }
Expand description
A libusb
context.
Implementations§
Source§impl Context
impl Context
Sourcepub fn set_log_level(&mut self, level: LogLevel)
pub fn set_log_level(&mut self, level: LogLevel)
Sets the log level of a libusb
context.
pub fn has_capability(&self) -> bool
Sourcepub fn has_hotplug(&self) -> bool
pub fn has_hotplug(&self) -> bool
Tests whether the running libusb
library supports hotplug.
Sourcepub fn has_hid_access(&self) -> bool
pub fn has_hid_access(&self) -> bool
Tests whether the running libusb
library has HID access.
Sourcepub fn supports_detach_kernel_driver(&self) -> bool
pub fn supports_detach_kernel_driver(&self) -> bool
Tests whether the running libusb
library supports detaching the kernel driver.
Sourcepub fn devices<'a>(&'a self) -> Result<DeviceList<'a>>
pub fn devices<'a>(&'a self) -> Result<DeviceList<'a>>
Returns a list of the current USB devices. The context must outlive the device list.
Sourcepub fn open_device_with_vid_pid(
&self,
vendor_id: u16,
product_id: u16,
) -> Option<DeviceHandle<'_>>
pub fn open_device_with_vid_pid( &self, vendor_id: u16, product_id: u16, ) -> Option<DeviceHandle<'_>>
Convenience function to open a device by its vendor ID and product ID.
This function is provided as a convenience for building prototypes without having to
iterate a DeviceList
. It is not meant for production
applications.
Returns a device handle for the first device found matching vendor_id
and product_id
.
On error, or if the device could not be found, it returns None
.
pub fn register_callback( &self, vendor_id: Option<u16>, product_id: Option<u16>, class: Option<u8>, callback: Box<dyn Hotplug>, ) -> Result<Registration>
Sourcepub fn unregister_callback(&self, reg: Registration)
pub fn unregister_callback(&self, reg: Registration)
TODO: fix handler leak
pub fn handle_events(&self, timeout: Option<Duration>) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Unpin for Context
impl UnwindSafe for Context
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more