pub fn open(&self) -> Result<TargetHandle<T>> {
        // Fetch endpoint sizes
        let config_descriptor = self.usb_device.active_config_descriptor()?;
        let interface_descriptor = config_descriptor
            .interfaces()
            .next()
            .ok_or(Error::IoError(rusb::Error::Io))?
            .descriptors()
            .next()
            .ok_or(Error::IoError(rusb::Error::Io))?;
        let mut endpoint_descriptors = interface_descriptor.endpoint_descriptors();
        let in_buffer_length = endpoint_descriptors
            .next()
            .ok_or(Error::IoError(rusb::Error::Io))?
            .max_packet_size();
        let out_buffer_length = endpoint_descriptors
            .next()
            .ok_or(Error::IoError(rusb::Error::Io))?
            .max_packet_size();

        // Open and reset device
        let mut device_handle = self.usb_device.open()?;
        device_handle.reset()?;

        Ok(TargetHandle {
            usb_device_handle: device_handle,
            in_buffer_length,
            out_buffer_length,
        })
    }
/// Connects to a target. Fails when errors occurr during USB communication.
Connects to a target. Fails when errors occurr during USB communication.
Connects to a target . Fails when errors occurr during USB communication .
pub fn open(&self) -> Result<TargetHandle<T>> {
        // Fetch endpoint sizes
        let config_descriptor = self.usb_device.active_config_descriptor()?;
        let interface_descriptor = config_descriptor
            .interfaces()
            .next()
            .ok_or(Error::IoError(rusb::Error::Io))?
            .descriptors()
            .next()
            .ok_or(Error::IoError(rusb::Error::Io))?;
        let mut endpoint_descriptors = interface_descriptor.endpoint_descriptors();
        let in_buffer_length = endpoint_descriptors
            .next()
            .ok_or(Error::IoError(rusb::Error::Io))?
            .max_packet_size();
        let out_buffer_length = endpoint_descriptors
            .next()
            .ok_or(Error::IoError(rusb::Error::Io))?
            .max_packet_size();
        // Open and reset device
        let mut device_handle = self.usb_device.open()?;
        device_handle.reset()?;
        Ok(TargetHandle {
            usb_device_handle: device_handle,
            in_buffer_length,
            out_buffer_length,
        })
    }
pub fn open ( & self ) -> Result < TargetHandle < T > > { // Fetch endpoint sizes let config_descriptor = self . usb_device . active_config_descriptor ( ) ? ; let interface_descriptor = config_descriptor . interfaces ( ) . next ( ) . ok_or ( Error :: IoError ( rusb :: Error :: Io ) ) ? . descriptors ( ) . next ( ) . ok_or ( Error :: IoError ( rusb :: Error :: Io ) ) ? ; let mut endpoint_descriptors = interface_descriptor . endpoint_descriptors ( ) ; let in_buffer_length = endpoint_descriptors . next ( ) . ok_or ( Error :: IoError ( rusb :: Error :: Io ) ) ? . max_packet_size ( ) ; let out_buffer_length = endpoint_descriptors . next ( ) . ok_or ( Error :: IoError ( rusb :: Error :: Io ) ) ? . max_packet_size ( ) ; // Open and reset device let mut device_handle = self . usb_device . open ( ) ? ; device_handle . reset ( ) ? ; Ok ( TargetHandle { usb_device_handle : device_handle , in_buffer_length , out_buffer_length , } ) }
Connects to a target.
Connects to a target .
&self
&self