With duplicate_keys = FALSE, the default, the
decoders now refuse a map two of whose keys become the same R value once
converted: 1 and the bignum 2(h'01'), a tag 0
and a tag 1 for one instant, [1] and [0x1801],
null and undefined, or "a" and
55799("a"). Such a map passed the duplicate-key check,
which compares tagged and container keys by their encoding, and gave a
cbor_map that cbor_encode() refused, or a list
with a repeated name. It is a zucbor_duplicate_key with
status "ZU_ERR_KEY_COLLISION" at the second key.
cbor_validate(), which converts nothing, still accepts it
(#74, #99, #100, #101, #105).
With map_keys = "string", a collision of stringified
keys now reports the offset of the second key, not of the map
(#104).
cbor_read_seq(each =): when an item could not be
built (a key collision, an integer under
big_integers = "error", a failing tag handler),
each now sees every item before it first, and the error’s
offset counts from the start of the stream. Before, items
read in the same block were lost and the offset was relative to the
block (#102).
A float64 NaN whose payload is that of R’s NA
decoded as NA_real_, so a peer could turn a float into a
missing value. Every NaN now decodes as NaN; typed arrays
still keep every bit (#103).
cbor_read() and cbor_read_seq() on a
connection that has been closed raise
zucbor_invalid_argument, not a bare R error
(#106).
cbor_encode(self_describe = TRUE) did not count tag
55799 toward max_depth, so it could write bytes that
cbor_decode() refuses at the same max_depth;
at 1023 levels, at any. The tag is now a level, as the decoder counts it
(#75).
The shared object exports only R_init_zucbor, so
TinyCBOR’s cbor_* functions and zucbor’s internal ones can
no longer clash with another package’s (#52).
cbor_diagnose() printed subnormal doubles wrongly on
Windows arm64, for example the smallest one as
3.3621031431120935e-4932 instead of 5.0e-324.
MinGW’s snprintf(), which R selects for compiled code
there, misreads them; zucbor now formats with the Windows C runtime
instead.
cbor_read() and cbor_read_seq(): a URL
or file that cannot be opened is a zucbor_io_error naming
the cause (HTTP status was '404 Not Found'), with no stray
warning (#54).
cbor_decode(), cbor_decode_seq(),
cbor_read() and cbor_read_seq() turn CBOR (RFC
8949) and CBOR sequences (RFC 8742) into ordinary R values. The whole
input is checked first – well-formedness, UTF-8, tag content, duplicate
map keys (by value), and depth, size and item limits – so a length
header can never make R allocate for data the input does not hold. Every
fault is a classed condition inheriting zucbor_error.cbor_encode() and cbor_encode_seq() write
RFC 8949 core deterministic encoding: identical R objects give identical
bytes on every platform, and decoding then re-encoding deterministic
input reproduces it exactly.cbor_annotate() prints an annotated hex dump: each head
with its offset, bytes and meaning, for reviewing a signed message byte
by byte.cbor_decode_prefix() decodes the item a raw vector
starts with and reports how many bytes it used, for CBOR inside binary
framing such as WebAuthn authData. What follows the item is
not read.cbor_encode(typed_arrays = TRUE) writes numeric vectors as
typed arrays and matrices as tag 1040: smaller, and much faster to read
and write. Off by default, so existing output is unchanged.data_frame = TRUE in the decoders reads such an
array (SenML, for instance) back as a data frame. max_cells
bounds the cells of a decoded frame before it is built.cbor_read_seq(each =) reads a sequence of any length in
memory bounded by its largest item: each item is checked whole, decoded
and passed to a function as soon as its last byte arrives. The limits
then apply per item.tag_handlers = in the decoders gives meaning to any
tag: a function per tag number turns its decoded content into an R
value. Handlers run only after the whole input has been checked, and an
error in one is zucbor_handler_error.
as_cbor() is the encoding half: an S3 generic that
cbor_encode() calls for any class it does not know.cbor_validate() runs the check alone;
cbor_diagnose() shows CBOR in RFC 8949 diagnostic notation,
as the RFC’s own examples write it.cbor_map(), cbor_tag(),
cbor_simple() and cbor_bigint() represent the
values R has no native type for: maps with non-text keys, tagged items,
simple values and integers beyond 2^53.