ndef

Crates.iondef
lib.rsndef
version0.4.0
created_at2024-12-18 13:37:51.540441+00
updated_at2025-06-12 13:19:42.671829+00
descriptionThis crate provides a `#[no_std]` library to implement a NFC Data Exchange Format structures.
homepage
repositoryhttps://github.com/Foundation-Devices/ndef-rs
max_upload_size
id1487587
size66,896
Georges (georgesFoundation)

documentation

README

ndef

Crates.io

#![no_std] Rust library to manipulate NDEF.

Features

  • alloc: enable a global allocator
    • allow more than 8 records per message
    • allow more than 256 bytes of payload size
    • allow to decode UTF-16 RTD Text record (always encoded in UTF-8)
    • allow to encode RTD external record
  • cbor: add minicbor dependency
    • provide a custom cbor RTD external record
    • provide a convenient record payload from cbor encodable type (need alloc too)

Example Usage

Cargo.toml

[dependencies]
ndef = "0.1.0"

main.rs

use ndef::{Message, Payload, Record, RecordType};

fn main() {
    let mut msg = Message::default();
    let mut rec1 = Record::new(
        None,
        Payload::RTD(RecordType::Text {
            enc: "en",
            txt: "NDEF Text from Rust🦀!",
        }),
    );
    msg.append_record(&mut rec1).unwrap();

    // Print message raw data
    println!("message raw data: {:?}", msg.to_vec().unwrap().as_slice());
}
Commit count: 0

cargo fmt