Expand description
Raw Rust FFI bindings for libnfc.
This crate follows the usual *-sys crate pattern: it exposes libnfc’s C API
with minimal translation and does not manage ownership, lifetimes, or error
handling for you. Most useful calls are unsafe because callers must satisfy
the same requirements as the corresponding native libnfc functions.
The nfc_context, nfc_device, and nfc_driver types are opaque because
libnfc treats them as incomplete public types. Use the accessor and lifecycle
functions exported by libnfc instead of relying on their internal layout.
§Linking
The build script links against a system-provided libnfc. On macOS it checks
common Homebrew locations. For custom installations, set LIBNFC_LIB_DIR to
the directory containing the native library.
§Example
use std::ffi::CStr;
use std::ptr;
use nfc_sys::{nfc_exit, nfc_init, nfc_version};
unsafe {
let mut context = ptr::null_mut();
nfc_init(&mut context);
if !context.is_null() {
let version = CStr::from_ptr(nfc_version()).to_string_lossy();
println!("libnfc version: {}", version);
nfc_exit(context);
}
}Structs§
- nfc_
barcode_ info - nfc_
context - Opaque libnfc context handle.
- nfc_
dep_ info - nfc_
device - Opaque libnfc device handle.
- nfc_
driver - Opaque libnfc driver handle.
- nfc_
emulation_ state_ machine - nfc_
emulator - nfc_
felica_ info - nfc_
iso14443a_ info - nfc_
iso14443b2ct_ info - nfc_
iso14443b2sr_ info - nfc_
iso14443b_ info - nfc_
iso14443bi_ info - nfc_
iso14443biclass_ info - nfc_
jewel_ info - nfc_
modulation - nfc_
target
Enums§
Constants§
- NFC_
BUFSIZE_ CONNSTRING - NFC_
ECHIP - NFC_
EDEVNOTSUPP - NFC_
EINVARG - NFC_EIO
- NFC_
EMFCAUTHFAIL - NFC_
ENOTIMPL - NFC_
ENOTSUCHDEV - NFC_
EOPABORTED - NFC_
EOVFLOW - NFC_
ERFTRANS - NFC_
ESOFT - NFC_
ETGRELEASED - NFC_
ETIMEOUT - NFC_
SUCCESS - NMT_
END_ ENUM
Functions§
- iso14443a_
crc ⚠ - iso14443a_
crc_ ⚠append - iso14443a_
locate_ ⚠historical_ bytes - iso14443b_
crc ⚠ - iso14443b_
crc_ ⚠append - nfc_
abort_ ⚠command - nfc_
close ⚠ - nfc_
device_ ⚠get_ connstring - nfc_
device_ ⚠get_ information_ about - nfc_
device_ ⚠get_ last_ error - nfc_
device_ ⚠get_ name - nfc_
device_ ⚠get_ supported_ baud_ rate - nfc_
device_ ⚠get_ supported_ baud_ rate_ target_ mode - nfc_
device_ ⚠get_ supported_ modulation - nfc_
device_ ⚠set_ property_ bool - nfc_
device_ ⚠set_ property_ int - nfc_
emulate_ ⚠target - nfc_
exit ⚠ - nfc_
free ⚠ - nfc_
idle ⚠ - nfc_
init ⚠ - nfc_
initiator_ ⚠deselect_ target - nfc_
initiator_ ⚠init - nfc_
initiator_ ⚠init_ secure_ element - nfc_
initiator_ ⚠list_ passive_ targets - nfc_
initiator_ ⚠poll_ dep_ target - nfc_
initiator_ ⚠poll_ target - nfc_
initiator_ ⚠select_ dep_ target - nfc_
initiator_ ⚠select_ passive_ target - nfc_
initiator_ ⚠target_ is_ present - nfc_
initiator_ ⚠transceive_ bits - nfc_
initiator_ ⚠transceive_ bits_ timed - nfc_
initiator_ ⚠transceive_ bytes - nfc_
initiator_ ⚠transceive_ bytes_ timed - nfc_
list_ ⚠devices - nfc_
open ⚠ - nfc_
perror ⚠ - nfc_
register_ ⚠driver - nfc_
strerror ⚠ - nfc_
strerror_ ⚠r - nfc_
target_ ⚠init - nfc_
target_ ⚠receive_ bits - nfc_
target_ ⚠receive_ bytes - nfc_
target_ ⚠send_ bits - nfc_
target_ ⚠send_ bytes - nfc_
version ⚠ - str_
nfc_ ⚠baud_ rate - str_
nfc_ ⚠modulation_ type - str_
nfc_ ⚠target