serde_describe
Make a non-self-describing serde format (like bincode,
bitcode or postcard)
behave as if it were self-describing by transparently serializing a schema
alongside (or separately from) the data.
use ;
use ;
// Non-self-describing formats don't generally support skipped
// fields and untagged unions, so let's use both.
// Roundtrip a `Vec` of `TopLevel` objects.
let original = vec!;
// Using the `SelfDescribed` wrapper, serialize as a combined
// "schema + object" pair. Use `bitcode` which is a particularly restrictive
// format.
let bytes = serialize?;
// Deserialize using the same wrapper to use the embedded schema.
let roundtripped =
?;
assert_eq!;
// Get a human-readable dump of the inferred schema for debugging.
assert_eq!;
Ok::