Open Nemo157 opened 6 years ago
A trivial way to improve this for now could be to output to JSON, CBOR diagnostic format is largely based on JSON anyway, it would just miss out on some of the features it doesn't support like non-string keys, tagged items, etc.
Also interesting would be a commented hex form, similar to what cbor.me supports
This is now using serde_cbor-diag
for rendering. Still not great though, since serde
isn't capable of representing the exact object model that CBOR uses. Looking at alternative libraries there is also cbor
which would allow getting the tagged information through. I don't think it supports getting whether a value was encoded with an indefinite encoding either.
Maybe it will be best to just write a custom &[u8] -> String
function.
Currently CBOR is being displayed using the debug output for
serde_cbor::Value
. This is not great,Instead it would be good to show the CBOR diagnostic notation, described in RFC 7049 §6. Maybe this could be done via a new
serde_cbor_diag
crate?As an example, the trivial message:
when output currently looks like
but encoded to CBOR diagnostic notation would appear as: