Make a non-self-describing serde format (like
bincode, bitcode or
postcard) behave as like a self-describing one by transparently
serializing a schema alongside (or separately from) the
data.
The main entry point to the crate is [SelfDescribed]. For advanced uses [SchemaBuilder]
and [Schema] may also be of interest.
use ;
use ;
// Define a type that non-self-describing formats would generally struggle
// with, using skipped fields and untagged unions.
// Serialize a `Vec<TopLevel>` using the `SelfDescribed` wrapper and bitcode, a
// particularly restrictive binary format.
let original = vec!;
let bytes = serialize?;
// Then deserialize using the same wrapper to use the embedded schema.
let roundtripped =
?;
assert_eq!;
# Ok::