Crates.io | nfc1 |
lib.rs | nfc1 |
version | 0.5.2 |
source | src |
created_at | 2021-05-02 16:54:28.639195 |
updated_at | 2023-04-27 18:50:41.469879 |
description | High-level safe Rust bindings for libnfc. |
homepage | |
repository | https://github.com/alexrsagen/rs-nfc1 |
max_upload_size | |
id | 392230 |
size | 90,203 |
High-level safe Rust bindings for libnfc.
This crate provides a safe wrapper around nfc1-sys
.
In contrast to nfc
, this crate additionally provides:
.unwrap()
where the it is not guaranteed to succeedResult<T, Error>
for methods which can failnfc1-sys
provides, which nfc-sys
does not
pn53x_*
, which are useful for accessing manufacturer-specific features in NFC devices)Add nfc1
as a dependency in your project's Cargo.toml
file:
[dependencies]
nfc1 = "0.5"
Import the nfc1
crate in your project, then you can use all the wrapped functions from libnfc
.
See the libnfc
wiki or libnfc
1.8.0 examples for information on how to use libnfc
.
fn main() -> nfc1::Result<()> {
println!("libnfc v{}", nfc1::version());
let mut context = nfc1::Context::new()?;
let mut device = context.open()?;
println!("NFC device {:?} opened through connection {:?}", device.name(), device.connstring());
println!("- Initiator modulations: {:?}", device.get_supported_modulation(nfc1::Mode::Initiator)?);
println!("- Target modulations: {:?}", device.get_supported_modulation(nfc1::Mode::Target)?);
Ok(())
}