ndef-rs

Crates.iondef-rs
lib.rsndef-rs
version0.2.2
sourcesrc
created_at2024-09-29 09:33:14.873742
updated_at2024-10-08 12:28:34.458341
descriptionNDEF (NFC Data Exchange Format) parser and generator in Rust
homepage
repository
max_upload_size
id1390749
size38,843
Cheng Tang (cashtang)

documentation

README

ndef-rs

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.

Features

  • Parse NDEF messages from byte arrays
  • Create NDEF messages from scratch
  • Support for common NDEF record types (e.g., Text, URI, MIME)
  • Easy-to-use API

Installation

Add the following to your Cargo.toml:

[dependencies]
ndef-rs = "0.2"

Usage

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

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For any questions or suggestions, please open an issue on GitHub.

Commit count: 0

cargo fmt