#nfc #record #ndef-message

no-std ndef

This crate provides a #[no_std] library to implement a NFC Data Exchange Format structures

3 releases (breaking)

0.5.0 Nov 25, 2025
0.4.0 Jun 12, 2025
0.2.0 Dec 18, 2024

#530 in No standard library

Download history 304/week @ 2025-11-23 830/week @ 2025-11-30 457/week @ 2025-12-07 397/week @ 2025-12-14 158/week @ 2025-12-21 78/week @ 2025-12-28 336/week @ 2026-01-04 251/week @ 2026-01-11 187/week @ 2026-01-18 159/week @ 2026-01-25 328/week @ 2026-02-01

932 downloads per month

GPL-3.0-or-later

34KB
551 lines

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 dcbor 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.5.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());
}

Dependencies

~0.2–1.5MB
~30K SLoC