pub struct Device<T: UsbContext> { /* private fields */ }
Expand description
A reference to a USB device.
Implementations
sourceimpl<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
Trait Implementations
sourceimpl<T: UsbContext> Clone for Device<T>
impl<T: UsbContext> Clone for Device<T>
sourceimpl<T: UsbContext> Debug for Device<T>
impl<T: UsbContext> Debug for Device<T>
impl<T: Eq + UsbContext> Eq for Device<T>
impl<T: UsbContext> Send for Device<T>
impl<T: UsbContext> StructuralEq for Device<T>
impl<T: UsbContext> StructuralPartialEq for Device<T>
impl<T: UsbContext> Sync for Device<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Device<T> where
T: RefUnwindSafe,
impl<T> Unpin for Device<T> where
T: Unpin,
impl<T> UnwindSafe for Device<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more