nfc-sys

Crates.ionfc-sys
lib.rsnfc-sys
version0.1.5
sourcesrc
created_at2016-05-30 23:31:40.296801
updated_at2016-09-16 17:57:32.83837
descriptionFFI bindings for the libnfc library
homepagehttps://github.com/dsgriffin/nfc-sys
repositoryhttps://github.com/dsgriffin/nfc-sys
max_upload_size
id5245
size23,537
Daniel Griffin (dsgriffin)

documentation

https://github.com/dsgriffin/nfc-sys

README

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

Commit count: 10

cargo fmt