6 releases

Uses old Rust 2015

0.1.5 Sep 16, 2016
0.1.4 Jun 20, 2016
0.1.2 May 30, 2016

#1916 in Hardware support

Download history 92/week @ 2024-07-29 32/week @ 2024-08-05 39/week @ 2024-08-12 20/week @ 2024-08-19 41/week @ 2024-08-26 39/week @ 2024-09-02 34/week @ 2024-09-09 30/week @ 2024-09-16 65/week @ 2024-09-23 43/week @ 2024-09-30 2/week @ 2024-10-07 31/week @ 2024-10-14 25/week @ 2024-10-21 38/week @ 2024-10-28 47/week @ 2024-11-04 9/week @ 2024-11-11

122 downloads per month
Used in 6 crates (4 directly)

MIT license

23KB
376 lines

nfc-sys

Crates.io

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);
    }
}

Contributing

I'm brand new to Rust so any help or constructive information would be really appreciated. Thanks in advance!

License

MIT

Dependencies

~44KB