fn try_from(device: Device<T>) -> Result<Target<T>> {
        // Constants used to identify the device. The shared VID:PID pair used here
        // mandates a check for the manufacturer and product strings
        const VENDOR_STRING: &str = "25120";
        const PRODUCT_STRING: &str = "punt";
        const VENDOR_ID: u16 = 0x16c0;
        const PRODUCT_ID: u16 = 0x05dc;

        let device_desc = device.device_descriptor()?;

        if device_desc.vendor_id() != VENDOR_ID || device_desc.product_id() != PRODUCT_ID {
            return Err(Error::UnsupportedTarget);
        }

        let device_handle = device.open()?;

        // Choose first language (the punt bootloader only supports English anyway)
        let language = device_handle.read_languages(TIMEOUT)?[0];

        let vendor_string =
            device_handle.read_manufacturer_string(language, &device_desc, TIMEOUT)?;
        let product_string = device_handle.read_product_string(language, &device_desc, TIMEOUT)?;

        if vendor_string != VENDOR_STRING || product_string != PRODUCT_STRING {
            return Err(Error::UnsupportedTarget);
        }

        Ok(Target { usb_device: device })
    }
/// Converts a raw USB device into a punt target if possible. If the USB device does not
/// reference a punt target, this function returns [`Err(Error::UnsupportedTarget)`].
///
/// [`Err(Error::UnsupportedTarget)`]: enum.Error.html#variant.UnsupportedTarget
Converts a raw USB device into a punt target if possible. If the USB device does not
reference a punt target, this function returns [`Err(Error::UnsupportedTarget)`].


Converts a raw USB device into a punt target if possible . If the USB device does not reference a punt target this function returns [ ` Err ( Error :: UnsupportedTarget ) ` ] .
fn try_from(device: Device<T>) -> Result<Target<T>> {
        // Constants used to identify the device. The shared VID:PID pair used here
        // mandates a check for the manufacturer and product strings
        const VENDOR_STRING: &str = "25120";
        const PRODUCT_STRING: &str = "punt";
        const VENDOR_ID: u16 = 0x16c0;
        const PRODUCT_ID: u16 = 0x05dc;
        let device_desc = device.device_descriptor()?;
        if device_desc.vendor_id() != VENDOR_ID || device_desc.product_id() != PRODUCT_ID {
            return Err(Error::UnsupportedTarget);
        }
        let device_handle = device.open()?;
        // Choose first language (the punt bootloader only supports English anyway)
        let language = device_handle.read_languages(TIMEOUT)?[0];
        let vendor_string =
            device_handle.read_manufacturer_string(language, &device_desc, TIMEOUT)?;
        let product_string = device_handle.read_product_string(language, &device_desc, TIMEOUT)?;
        if vendor_string != VENDOR_STRING || product_string != PRODUCT_STRING {
            return Err(Error::UnsupportedTarget);
        }
        Ok(Target { usb_device: device })
    }
fn try_from ( device : Device < T > ) -> Result < Target < T > > { // Constants used to identify the device. The shared VID:PID pair used here // mandates a check for the manufacturer and product strings const VENDOR_STRING : & str = " " ; const PRODUCT_STRING : & str = " " ; const VENDOR_ID : u16 = 0x16c0 ; const PRODUCT_ID : u16 = 0x05dc ; let device_desc = device . device_descriptor ( ) ? ; if device_desc . vendor_id ( ) != VENDOR_ID || device_desc . product_id ( ) != PRODUCT_ID { return Err ( Error :: UnsupportedTarget ) ; } let device_handle = device . open ( ) ? ; // Choose first language (the punt bootloader only supports English anyway) let language = device_handle . read_languages ( TIMEOUT ) ? [ 0 ] ; let vendor_string = device_handle . read_manufacturer_string ( language , & device_desc , TIMEOUT ) ? ; let product_string = device_handle . read_product_string ( language , & device_desc , TIMEOUT ) ? ; if vendor_string != VENDOR_STRING || product_string != PRODUCT_STRING { return Err ( Error :: UnsupportedTarget ) ; } Ok ( Target { usb_device : device } ) }
Converts a raw USB device into a punt target if possible.
Converts a raw USB device into a punt target if possible .
device
Device<T>
device
Device<T>