pub struct Device<T: UsbContext> { /* private fields */ }
Expand description
A reference to a USB device.
Implementations§
source§impl<T: UsbContext> Device<T>
impl<T: UsbContext> Device<T>
sourcepub fn as_raw(&self) -> *mut libusb_device
pub fn as_raw(&self) -> *mut libusb_device
Get the raw libusb_device pointer, for advanced use in unsafe code
sourcepub unsafe fn from_libusb(
context: T,
device: NonNull<libusb_device>
) -> Device<T>
pub unsafe fn from_libusb(
context: T,
device: NonNull<libusb_device>
) -> Device<T>
Safety
Converts an existing libusb_device
pointer into a Device<T>
.
device
must be a pointer to a valid libusb_device
. Rusb increments refcount.
sourcepub fn device_descriptor(&self) -> Result<DeviceDescriptor>
pub fn device_descriptor(&self) -> Result<DeviceDescriptor>
Reads the device descriptor.
sourcepub fn config_descriptor(&self, config_index: u8) -> Result<ConfigDescriptor>
pub fn config_descriptor(&self, config_index: u8) -> Result<ConfigDescriptor>
Reads a configuration descriptor.
sourcepub fn active_config_descriptor(&self) -> Result<ConfigDescriptor>
pub fn active_config_descriptor(&self) -> Result<ConfigDescriptor>
Reads the configuration descriptor for the current configuration.
sourcepub fn bus_number(&self) -> u8
pub fn bus_number(&self) -> u8
Returns the number of the bus that the device is connected to.
sourcepub fn open(&self) -> Result<DeviceHandle<T>>
pub fn open(&self) -> Result<DeviceHandle<T>>
Opens the device.
sourcepub fn port_number(&self) -> u8
pub fn port_number(&self) -> u8
Returns the device’s port number
sourcepub fn get_parent(&self) -> Option<Self>
pub fn get_parent(&self) -> Option<Self>
Returns the device’s parent