Can anyone point me to a serde data format that uses multiple distinct string representations?

Or a serde data format that isn't self-describing?

Or a serde data format that has distinct "top level" types that are different from inner types

Unfortunately I'm implementing a data format that has all of these things and it's making serde hard

#rustlang #rust #serde

@asonix The closest example I can give is 8 RFC numbers off what you're doing:
In CBOR, there exists both a byte-string type, and an array type (that can, among other things, contain integers). So any CBOR serde binding, when faced with a &[u8], has to make a choice between "it's obviously bytes" (byte string) and "it's a special case of &[T]" (array of numbers).

I think what they do is that they make users go through newtypes in the serialized side <https://docs.rs/minicbor/latest/minicbor/bytes/index.html>.

minicbor::bytes - Rust

Newtypes for `&[u8]`, `[u8;N]` and `Vec<u8>`.

@asonix Not 100% sure if it really works that way, though: There are a lot of other friction points with serde, eg. that it doesn't support integer keys serialized structs, so maybe those newtypes just work when going through minicbor's own derives rather than through serde's.