pub fn transmit_control<'receive_buffer>(&self, control_code: ControlCode, send_buffer: &[u8], receive_buffer: &'receive_buffer mut [MaybeUninit<u8>]) -> Result<&'receive_buffer [u8], CardCommandError>
	{
		let send_buffer_length = send_buffer.len();
		debug_assert!(send_buffer_length <= Context::MaximumExtendedSendOrReceiveBufferSize);
		
		let receive_buffer_length = receive_buffer.len();
		debug_assert!(receive_buffer_length <= Context::MaximumExtendedSendOrReceiveBufferSize);
		
		let handle = self.handle();
		let control_code = control_code.into_DWORD();
		let send_buffer_pointer = send_buffer.as_ptr();
		let send_buffer_length = send_buffer.len() as DWORD;
		let receive_buffer_pointer = receive_buffer.as_mut_ptr() as *mut u8;
		let receive_buffer_length = receive_buffer_length as DWORD;
		let mut bytes_returned: MaybeUninit<DWORD> = MaybeUninit::uninit();
		let bytes_returned_pointer = bytes_returned.as_mut_ptr();
		
		let mut remaining_reset_retry_attempts = self.remaining_reset_retry_attempts();
		loop
		{
			let result = unsafe { SCardControl(handle, control_code, send_buffer_pointer, send_buffer_length, receive_buffer_pointer, receive_buffer_length, bytes_returned_pointer) };
			
			if likely!(result == SCARD_S_SUCCESS)
			{
				let receive_buffer_length = (unsafe { bytes_returned.assume_init() }) as usize;
				let slice = receive_buffer.get_unchecked_range_safe(.. receive_buffer_length);
				let receive_buffer = unsafe { MaybeUninit::slice_assume_init_ref(slice) };
				
				return Ok(receive_buffer)
			}
			
			use CardCommandError::*;
			use CardStatusError::*;
			use CardTransmissionError::*;
			use ReconnectionUnavailableOrCommunicationError::*;
			use UnavailableOrCommunicationError::*;
			use UnavailableError::*;
			use CommunicationError::*;
			let error = match result
			{
				SCARD_W_RESET_CARD if self.connected_card.is_shared =>
				{
					remaining_reset_retry_attempts.card_was_reset::<CardCommandError>(&self.connected_card)?;
					continue
				}
				
				SCARD_E_INSUFFICIENT_BUFFER =>
				{
					let receive_buffer_length = (unsafe { bytes_returned.assume_init() }) as usize;
					ReceiveBufferIsTooSmall { minimum_size_required: receive_buffer_length  }
				},
				
				SCARD_E_NOT_TRANSACTED => CardTransmission(DataExchangeWithCardFailed),
				
				SCARD_W_UNPOWERED_CARD => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Unavailable(CardIsUnpowered))))),
				
				SCARD_W_UNRESPONSIVE_CARD => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Unavailable(CardIsMute))))),
				
				SCARD_W_REMOVED_CARD => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Unavailable(CardRemoved))))),
				
				SCARD_E_NO_SMARTCARD => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Unavailable(NoCard))))),
				
				SCARD_E_READER_UNAVAILABLE => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Unavailable(CardReaderUnavailable))))),
				
				SCARD_E_NO_MEMORY => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Communication(OutOfMemory))))),
				
				SCARD_E_NO_SERVICE => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Communication(ThereIsNoDaemonRunningOrConnectionWithTheDaemonCouldNotBeEstablished))))),
				
				SCARD_F_COMM_ERROR => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Communication(InternalCommunications))))),
				
				SCARD_F_INTERNAL_ERROR => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Communication(InternalError))))),
				
				SCARD_E_PROTO_MISMATCH => panic!("pioSendPci / pioRecvPci protocol mismatch; not sure how this is possible"),
				
				SCARD_E_INVALID_VALUE => unreachable!("Provided suitable parameters"),
				
				SCARD_E_INVALID_PARAMETER => unreachable!("Provided non-null parameters"),
				
				SCARD_E_INVALID_HANDLE => unreachable!("Invalid context handle"),
				
				_ => unreachable!("Undocumented error {} from SCardSetAttrib()", result),
			};
			return Err(error)
		}
	}
/// Sends a command directly to the IFD Handler (Card Reader driver) to be processed by the Card Reader.
///
/// Ideally, make sure `receive_buffer` is `Context::MaximumSendOrReceiveBufferSizeExtended`.
Sends a command directly to the IFD Handler (Card Reader driver) to be processed by the Card Reader.
Sends a command directly to the IFD Handler ( Card Reader driver ) to be processed by the Card Reader .
pub fn transmit_control<'receive_buffer>(&self, control_code: ControlCode, send_buffer: &[u8], receive_buffer: &'receive_buffer mut [MaybeUninit<u8>]) -> Result<&'receive_buffer [u8], CardCommandError>
	{
		let send_buffer_length = send_buffer.len();
		debug_assert!(send_buffer_length <= Context::MaximumExtendedSendOrReceiveBufferSize);
		let receive_buffer_length = receive_buffer.len();
		debug_assert!(receive_buffer_length <= Context::MaximumExtendedSendOrReceiveBufferSize);
		let handle = self.handle();
		let control_code = control_code.into_DWORD();
		let send_buffer_pointer = send_buffer.as_ptr();
		let send_buffer_length = send_buffer.len() as DWORD;
		let receive_buffer_pointer = receive_buffer.as_mut_ptr() as *mut u8;
		let receive_buffer_length = receive_buffer_length as DWORD;
		let mut bytes_returned: MaybeUninit<DWORD> = MaybeUninit::uninit();
		let bytes_returned_pointer = bytes_returned.as_mut_ptr();
		let mut remaining_reset_retry_attempts = self.remaining_reset_retry_attempts();
		loop
		{
			let result = unsafe { SCardControl(handle, control_code, send_buffer_pointer, send_buffer_length, receive_buffer_pointer, receive_buffer_length, bytes_returned_pointer) };
			if likely!(result == SCARD_S_SUCCESS)
			{
				let receive_buffer_length = (unsafe { bytes_returned.assume_init() }) as usize;
				let slice = receive_buffer.get_unchecked_range_safe(.. receive_buffer_length);
				let receive_buffer = unsafe { MaybeUninit::slice_assume_init_ref(slice) };
				return Ok(receive_buffer)
			}
			use CardCommandError::*;
			use CardStatusError::*;
			use CardTransmissionError::*;
			use ReconnectionUnavailableOrCommunicationError::*;
			use UnavailableOrCommunicationError::*;
			use UnavailableError::*;
			use CommunicationError::*;
			let error = match result
			{
				SCARD_W_RESET_CARD if self.connected_card.is_shared =>
				{
					remaining_reset_retry_attempts.card_was_reset::<CardCommandError>(&self.connected_card)?;
					continue
				}
				SCARD_E_INSUFFICIENT_BUFFER =>
				{
					let receive_buffer_length = (unsafe { bytes_returned.assume_init() }) as usize;
					ReceiveBufferIsTooSmall { minimum_size_required: receive_buffer_length  }
				},
				SCARD_E_NOT_TRANSACTED => CardTransmission(DataExchangeWithCardFailed),
				SCARD_W_UNPOWERED_CARD => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Unavailable(CardIsUnpowered))))),
				SCARD_W_UNRESPONSIVE_CARD => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Unavailable(CardIsMute))))),
				SCARD_W_REMOVED_CARD => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Unavailable(CardRemoved))))),
				SCARD_E_NO_SMARTCARD => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Unavailable(NoCard))))),
				SCARD_E_READER_UNAVAILABLE => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Unavailable(CardReaderUnavailable))))),
				SCARD_E_NO_MEMORY => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Communication(OutOfMemory))))),
				SCARD_E_NO_SERVICE => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Communication(ThereIsNoDaemonRunningOrConnectionWithTheDaemonCouldNotBeEstablished))))),
				SCARD_F_COMM_ERROR => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Communication(InternalCommunications))))),
				SCARD_F_INTERNAL_ERROR => CardTransmission(CardStatus(ReconnectionUnavailableOrCommunication(UnavailableOrCommunication(Communication(InternalError))))),
				SCARD_E_PROTO_MISMATCH => panic!("pioSendPci / pioRecvPci protocol mismatch; not sure how this is possible"),
				SCARD_E_INVALID_VALUE => unreachable!("Provided suitable parameters"),
				SCARD_E_INVALID_PARAMETER => unreachable!("Provided non-null parameters"),
				SCARD_E_INVALID_HANDLE => unreachable!("Invalid context handle"),
				_ => unreachable!("Undocumented error {} from SCardSetAttrib()", result),
			};
			return Err(error)
		}
	}
pub fn transmit_control < ' receive_buffer > ( & self , control_code : ControlCode , send_buffer : & [ u8 ] , receive_buffer : & ' receive_buffer mut [ MaybeUninit < u8 > ] ) -> Result < & ' receive_buffer [ u8 ] , CardCommandError > { let send_buffer_length = send_buffer . len ( ) ; debug_assert ! ( send_buffer_length Context MaximumExtendedSendOrReceiveBufferSize ) ; let receive_buffer_length = receive_buffer . len ( ) ; debug_assert ! ( receive_buffer_length Context MaximumExtendedSendOrReceiveBufferSize ) ; let handle = self . handle ( ) ; let control_code = control_code . into_DWORD ( ) ; let send_buffer_pointer = send_buffer . as_ptr ( ) ; let send_buffer_length = send_buffer . len ( ) as DWORD ; let receive_buffer_pointer = receive_buffer . as_mut_ptr ( ) as * mut u8 ; let receive_buffer_length = receive_buffer_length as DWORD ; let mut bytes_returned : MaybeUninit < DWORD > = MaybeUninit :: uninit ( ) ; let bytes_returned_pointer = bytes_returned . as_mut_ptr ( ) ; let mut remaining_reset_retry_attempts = self . remaining_reset_retry_attempts ( ) ; loop { let result = unsafe { SCardControl ( handle , control_code , send_buffer_pointer , send_buffer_length , receive_buffer_pointer , receive_buffer_length , bytes_returned_pointer ) } ; if likely ! ( result SCARD_S_SUCCESS ) { let receive_buffer_length = ( unsafe { bytes_returned . assume_init ( ) } ) as usize ; let slice = receive_buffer . get_unchecked_range_safe ( .. receive_buffer_length ) ; let receive_buffer = unsafe { MaybeUninit :: slice_assume_init_ref ( slice ) } ; return Ok ( receive_buffer ) } use CardCommandError :: * ; use CardStatusError :: * ; use CardTransmissionError :: * ; use ReconnectionUnavailableOrCommunicationError :: * ; use UnavailableOrCommunicationError :: * ; use UnavailableError :: * ; use CommunicationError :: * ; let error = match result { SCARD_W_RESET_CARD if self . connected_card . is_shared => { remaining_reset_retry_attempts . card_was_reset :: < CardCommandError > ( & self . connected_card ) ? ; continue } SCARD_E_INSUFFICIENT_BUFFER => { let receive_buffer_length = ( unsafe { bytes_returned . assume_init ( ) } ) as usize ; ReceiveBufferIsTooSmall { minimum_size_required : receive_buffer_length } } , SCARD_E_NOT_TRANSACTED => CardTransmission ( DataExchangeWithCardFailed ) , SCARD_W_UNPOWERED_CARD => CardTransmission ( CardStatus ( ReconnectionUnavailableOrCommunication ( UnavailableOrCommunication ( Unavailable ( CardIsUnpowered ) ) ) ) ) , SCARD_W_UNRESPONSIVE_CARD => CardTransmission ( CardStatus ( ReconnectionUnavailableOrCommunication ( UnavailableOrCommunication ( Unavailable ( CardIsMute ) ) ) ) ) , SCARD_W_REMOVED_CARD => CardTransmission ( CardStatus ( ReconnectionUnavailableOrCommunication ( UnavailableOrCommunication ( Unavailable ( CardRemoved ) ) ) ) ) , SCARD_E_NO_SMARTCARD => CardTransmission ( CardStatus ( ReconnectionUnavailableOrCommunication ( UnavailableOrCommunication ( Unavailable ( NoCard ) ) ) ) ) , SCARD_E_READER_UNAVAILABLE => CardTransmission ( CardStatus ( ReconnectionUnavailableOrCommunication ( UnavailableOrCommunication ( Unavailable ( CardReaderUnavailable ) ) ) ) ) , SCARD_E_NO_MEMORY => CardTransmission ( CardStatus ( ReconnectionUnavailableOrCommunication ( UnavailableOrCommunication ( Communication ( OutOfMemory ) ) ) ) ) , SCARD_E_NO_SERVICE => CardTransmission ( CardStatus ( ReconnectionUnavailableOrCommunication ( UnavailableOrCommunication ( Communication ( ThereIsNoDaemonRunningOrConnectionWithTheDaemonCouldNotBeEstablished ) ) ) ) ) , SCARD_F_COMM_ERROR => CardTransmission ( CardStatus ( ReconnectionUnavailableOrCommunication ( UnavailableOrCommunication ( Communication ( InternalCommunications ) ) ) ) ) , SCARD_F_INTERNAL_ERROR => CardTransmission ( CardStatus ( ReconnectionUnavailableOrCommunication ( UnavailableOrCommunication ( Communication ( InternalError ) ) ) ) ) , SCARD_E_PROTO_MISMATCH => panic ! ( " " ) , SCARD_E_INVALID_VALUE => unreachable ! ( " " ) , SCARD_E_INVALID_PARAMETER => unreachable ! ( " " ) , SCARD_E_INVALID_HANDLE => unreachable ! ( " " ) , _ => unreachable ! ( " " result ) , } ; return Err ( error ) } }
Sends a command directly to the IFD Handler (Card Reader driver) to be processed by the Card Reader.
Sends a command directly to the IFD Handler ( Card Reader driver ) to be processed by the Card Reader .
&self
control_code
ControlCode
send_buffer
&[u8]
receive_buffer
&'receive_buffer mut [MaybeUninit<u8>]
&self
control_code
ControlCode
send_buffer
&[u8]
receive_buffer
&'receive_buffer mut [MaybeUninit<u8>]