Trait punt::UsbContext
source · pub trait UsbContext: UsbContext {
// Provided methods
fn find_targets(&self) -> Result<Vec<Target<Self>>> { ... }
fn pick_target(&self, serial: Option<&str>) -> Result<Target<Self>> { ... }
}
Expand description
Base trait for a USB context.
Provided Methods§
sourcefn find_targets(&self) -> Result<Vec<Target<Self>>>
fn find_targets(&self) -> Result<Vec<Target<Self>>>
Returns information about all connected targets in bootloader mode. USB devices not in bootloader mode cannot be detected, since their protocol for entering bootloader mode is not specified.
It returns Error::IoError
on USB errors during device enumeration.
sourcefn pick_target(&self, serial: Option<&str>) -> Result<Target<Self>>
fn pick_target(&self, serial: Option<&str>) -> Result<Target<Self>>
Returns one target if either
- A serial number is supplied which matches one of the connected targets’ serial numbers or
- Only one target is connected and either no serial number is supplied or the serial number matches.
It can return the following errors:
Error::TargetNotFound
if no target is found based on the criteria above,Error::TooManyMatches
if more than one target is connected but no serial number is supplied, andError::IoError
for any libusb errors occurring during USB transfers.
Just like with find_targets
, only targets in bootloader mode are considered.