| cbor_decode_prefix | R Documentation |
Decodes the one CBOR data item that x starts with and reports how many
bytes it used, for CBOR inside binary framing: a COSE key in the middle
of WebAuthn authData, or a payload after a fixed header. The item is
checked and decoded exactly as by cbor_decode(), with the same
arguments; what follows it is not read at all.
cbor_decode_prefix(
x,
simplify = c("preserve", "none"),
map_keys = c("auto", "map", "string"),
tags = c("convert", "keep"),
big_integers = c("bigint", "double", "error"),
duplicate_keys = FALSE,
deterministic = FALSE,
max_depth = 256L,
max_size = 64 * 1024^2,
max_items = 1e+06,
tag_handlers = NULL,
data_frame = FALSE,
max_cells = 1e+07
)
x |
A raw vector starting with a CBOR data item. |
simplify |
|
map_keys |
|
tags |
|
big_integers |
What to do with an integer beyond 2^53, which a
double cannot hold exactly: |
duplicate_keys |
If |
deterministic |
If |
max_depth |
Deepest nesting allowed, counting arrays, maps and tags.
At most |
max_size |
Largest input allowed, in bytes, or |
max_items |
Most data items allowed, counting every tag and every
chunk of an indefinite-length string, or |
tag_handlers |
|
data_frame |
If |
max_cells |
With |
That also means nothing about the rest is known: it may be more CBOR, or
the next field of the framing, or garbage. It is the caller's to make
sense of, as x[-seq_len(consumed)].
max_size applies to x as a whole, since all of it is in memory
already. An empty x is zucbor_parse_error, as for cbor_decode();
so is an item cut short by the end of x.
A list: value, the decoded item, and consumed, the number of
bytes it took, a double.
cbor_decode() for one item and nothing else, and
cbor_decode_seq() for items all the way to the end.
# [1, 2] followed by four bytes of something else.
x <- as.raw(c(0x82, 0x01, 0x02, 0xde, 0xad, 0xbe, 0xef))
r <- cbor_decode_prefix(x)
r$value
x[-seq_len(r$consumed)]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.