Library providing a self-describing, byte format which works with serde?

Hello, I am looking for a serde format which, unlike postcard is self-describing, and unlike bincode, works well with serde and lets you use serde attributes like flatten, etc. It also needs to be self-describing because its important for me to deserialize into fields and that I am using typetag, which basically REQUIRES a self-describing format. It would be even better if you could use COBS with this format also.

does serde_with Bytes do the job?

serde.rs lists several other binary formats:

  • CBOR, a Concise Binary Object Representation designed for small message size without the need for version negotiation.
  • MessagePack, an efficient binary format that resembles a compact JSON.
  • Pickle, a format common in the Python world.
  • BSON, the data storage and network transfer format used by MongoDB.
  • Avro, a binary format used within Apache Hadoop, with support for schema definition.
  • D-Bus's binary wire format.
  • FlexBuffers, the schemaless cousin of Google's FlatBuffers zero-copy serialization format.
  • Bencode, a simple binary format used in the BitTorrent protocol.

I'm not sure which of these meets your requirements because the claim that because you're "type tagging" you can't use a non-self-describing format doesn't make a huge amount of sense to me: assuming you mean a tagged enum representation, those aren't exclusive.

Regardless, most of these at least claim support for schemaless encoding, which means self describing, so hopefully you find something you like.

I'm not familiar with COBS, but for a general-purpose, self-describing, binary format, I like MsgPack. It's usually directly swappable with JSON for many applications.