/// Read APDU into given buffer.  Return length of APDU on success.
Read APDU into given buffer.  Return length of APDU on success.
Read APDU into given buffer . Return length of APDU on success .
fn check_for_apdu(&mut self) -> Result<(), SourceError> {
        let mut packet = MaybeUninit::<[u8; 256]>::uninit();
        let packet = unsafe { &mut *packet.as_mut_ptr() };
        let res = self.device.read(packet);
        let packet_len = match res {
            Ok(nfc::State::NewSession(x)) => {
                info!("State::NewSession");
                self.reset_state();
                x
            },
            Ok(nfc::State::Continue(x)) => x,
            Err(nfc::Error::NewSession) => {
                info!("Error::NewSession");
                self.reset_state();
                return Err(SourceError::NoActivity)
            },
            _ => {
                // info!("nop");
                return Err(SourceError::NoActivity)
            }
        };
        assert!(packet_len > 0);
        // let packet = &self.packet;
        self.handle_block(&packet[.. packet_len as usize])?;
        debug!(">>");
        debug!("{}", hex_str!(&self.buffer, sep:""));
        // logging::dump_hex(packet, l as usize);
        let command = interchanges::Data::from_slice(&self.buffer);
        self.buffer.clear();
        if command.is_ok() {
            if self.interchange.request(
                command.as_ref().unwrap()
            ).is_ok() {
                Ok(())
            } else {
                // Would be better to try canceling and taking on this apdu.
                info!("Had to drop most recent Apdu!");
                Err(SourceError::NoActivity)
            }
        } else {
            let (frame, _) = self.construct_iblock(
                // UnspecifiedCheckingError
                &[0x6F, 0x00]
            );
            self.send_frame( &frame )?;
            Err(SourceError::NoActivity)
        }
    }
fn check_for_apdu ( & mut self ) -> Result < ( ) , SourceError > { let mut packet = MaybeUninit :: < [ u8 ; 256 ] > :: uninit ( ) ; let packet = unsafe { & mut * packet . as_mut_ptr ( ) } ; let res = self . device . read ( packet ) ; let packet_len = match res { Ok ( nfc :: State :: NewSession ( x ) ) => { info ! ( " " ) ; self . reset_state ( ) ; x } , Ok ( nfc :: State :: Continue ( x ) ) => x , Err ( nfc :: Error :: NewSession ) => { info ! ( " " ) ; self . reset_state ( ) ; return Err ( SourceError :: NoActivity ) } , _ => { // info!("nop"); return Err ( SourceError :: NoActivity ) } } ; assert ! ( packet_len 0 ) ; // let packet = &self.packet; self . handle_block ( & packet [ .. packet_len as usize ] ) ? ; debug ! ( " " ) ; debug ! ( " " hex_str ( self buffer sep " " ) ) ; // logging::dump_hex(packet, l as usize); let command = interchanges :: Data :: from_slice ( & self . buffer ) ; self . buffer . clear ( ) ; if command . is_ok ( ) { if self . interchange . request ( command . as_ref ( ) . unwrap ( ) ) . is_ok ( ) { Ok ( ( ) ) } else { // Would be better to try canceling and taking on this apdu. info ! ( " " ) ; Err ( SourceError :: NoActivity ) } } else { let ( frame , _ ) = self . construct_iblock ( // UnspecifiedCheckingError & [ 0x6F , 0x00 ] ) ; self . send_frame ( & frame ) ? ; Err ( SourceError :: NoActivity ) } }
Read APDU into given buffer.
Read APDU into given buffer .
&mut self