pub fn display<'b>(cbor: &'b [u8]) -> impl Display + 'b
Expand description
Display the given CBOR bytes in diagnostic notation.
Requires features "alloc"
and "half"
.
Quick syntax summary:
- Maps are enclosed in curly braces:
{
and}
. - Arrays are enclosed in brackets:
[
and]
. - Indefinite maps start with
{_
instead of{
. - Indefinite arrays start with
[_
instead of[
. - Bytes are hex encoded and enclosed in
h'
and'
. - Strings are enclosed in double quotes.
- Numbers and booleans are displayed as in Rust but floats are always shown in scientific notation (this differs slightly from the RFC format).
- Indefinite bytes are enclosed in
(_
and)
except for the empty sequence which is shown as''_
. - Indefinite strings are enclosed in
(_
and)
except for the empty sequence which is shown as""_
. - Tagged values are enclosed in
t(
and)
wheret
is the numeric tag value. - Simple values are shown as
simple(n)
wheren
is the numeric simple value. - Undefined and null are shown as
undefined
andnull
.
No error is produced should decoding fail, the error message becomes part of the display.