Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

dsgriffin/nfc-sys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nfc-sys

Crates.io

IMPORTANT - nfc-sys Crate Deprecated

This crate has not had an update in many years; please use the nfc1-sys crate instead.


nfc-sys provides FFI bindings to libnfc.

Following the *-sys package conventions, the nfc-sys package does not define higher-level abstractions over the native library; for a safe implementation, see nfc.

Installation

Install libnfc (e.g. Debian/Ubuntu, brew install libnfc using Homebrew on Mac OSx, or on other systems).

Cargo.toml

[dependencies]
libc = "0.2.0"
nfc-sys = "0.1.4"

Example Usage

// main.rs

extern crate nfc_sys;

use ::std::ffi::CStr;

fn main() {
    unsafe {
         // Create new Context and initialize libnfc
         let mut context = nfc_sys::nfc_context_new();
         nfc_sys::nfc_init(&mut context);
    
         if context.is_null() {
             println!("Unable to initialize new nfc context");
         }
    
         let version = CStr::from_ptr(nfc_sys::nfc_version()).to_str().unwrap();
    
         println!("libnfc version: {:?}", version);
    }
}

Crates.io Package

https://crates.io/crates/nfc-sys

Contributing

Check out the "issues" tab. Also, if you'd like to add any kind of improvement (or have a suggestion), I would be grateful! Thanks.

License

MIT