cbor_next

Crates.iocbor_next
lib.rscbor_next
version0.3.0
created_at2025-06-13 12:52:05.364932+00
updated_at2025-06-16 12:42:59.209887+00
descriptionCBOR encoder and decoder
homepagehttps://github.com/iamsauravsharma/cbor_next
repositoryhttps://github.com/iamsauravsharma/cbor_next
max_upload_size
id1711432
size94,709
Saurav Sharma (iamsauravsharma)

documentation

README

CBOR Next

Library to encode and decode a Concise Binary Object Representation (CBOR)

License Crates Version Docs
License: MIT Crate Docs

Features

  • Complete support for all major CBOR types (unsigned, signed, floating integers, bytes, text, array, map, tag, boolean, null, undefined and other simple value)
  • RFC 8949 compliant
  • Deterministic encoding support via DeterministicMode
  • Encoding/Decoding to and from CBOR binary format

Installation

Add cbor_next to your Cargo.toml

cbor_next = "0.3.0"

Usage

Main building block of library is DataItem Enum which represent a different type CBOR data item

Encoding

use cbor_next::DataItem;
let value = DataItem::Unsigned(10_000_000);
let vector_data = vec![0x1a, 0x00, 0x98, 0x96, 0x80];
assert_eq!(value.encode(), vector_data);

Decoding

use cbor_next::DataItem;
let vector_data = vec![0x1a, 0x00, 0x98, 0x96, 0x80];
let value = DataItem::Unsigned(10_000_000);
assert_eq!(DataItem::decode(&vector_data).unwrap(), value);

For other usage check out docs Value enum and its methods and functions

Commit count: 34

cargo fmt