nfc_device_get_data

Function nfc_device_get_data 

Source
pub unsafe extern "C" fn nfc_device_get_data(
    instance: *const NfcDevice,
    protocol: NfcProtocol,
) -> *const NfcDeviceData
Expand description

Get the protocol-specific data from an NfcDevice instance.

The protocol parameter’s behaviour is a bit tricky. The function will check whether there is such a protocol somewhere in the protocol hierarchy and return the data exactly from that level.

Example: Call nfc_device_get_data() on an instance with Mf DESFire protocol. The protocol hierarchy will look like the following:

Mf DESFire --> ISO14443-4A --> ISO14443-3A

Thus, the following values of the protocol parameter are valid:

  • NfcProtocolIso14443_3a
  • NfcProtocolIso14443_4a
  • NfcProtocolMfDesfire

and passing them to the call would result in the respective data being returned.

However, supplying a protocol identifier which is not in the hierarchy will result in a crash. This is to improve type safety.

§Arguments

  • instance - pointer to the instance to be queried
  • protocol - protocol identifier of the data to be retrieved.

§Returns

pointer to the instance’s data.