Crates.io | ndef-rs |
lib.rs | ndef-rs |
version | 0.2.2 |
source | src |
created_at | 2024-09-29 09:33:14.873742 |
updated_at | 2024-10-08 12:28:34.458341 |
description | NDEF (NFC Data Exchange Format) parser and generator in Rust |
homepage | |
repository | |
max_upload_size | |
id | 1390749 |
size | 38,843 |
ndef-rs
is a Rust library for working with NFC Data Exchange Format (NDEF) messages. This library provides functionality to parse, create, and manipulate NDEF messages in a convenient and efficient manner.
Add the following to your Cargo.toml
:
[dependencies]
ndef-rs = "0.2"
Here is a simple example of how to use ndef-rs
:
use ndef_rs::{NdefMessage, NdefRecord};
use ndef_rs::payload::TextPayload;
fn main() {
// Create a new NDEF message
let payload = TextPayload::from_static("Hello, world!");
let record = NdefRecord::builder()
.tnf(TNF::WellKnown)
.payload(&payload)
.build()
.unwrap();
let ndef_message = NdefMessage::from(&[text_record]);
// Convert the NDEF message to bytes
let bytes = ndef_message.to_buffer().unwrap();
println!("{:?}", bytes);
// Parse the NDEF message from bytes
let parsed_message = NdefMessage::decode(&bytes).unwrap();
println!("{:?}", parsed_message);
}
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or suggestions, please open an issue on GitHub.