musli-storage
Super simple storage encoding for Müsli
The storage encoding is partially upgrade safe:
- ✔ Can tolerate missing fields if they are annotated with
#[musli(default)]
. - ✗ Cannot skip over extra unrecognized fields.
This means that it's suitable as a storage format, since the data model only evolves in one place. But unsuitable as a wire format since it cannot allow clients to upgrade independent of each other.
See musli-wire for a fully upgrade safe format.
use ;
let version2 = to_vec?;
assert!;
let version1 = to_vec?;
let version2: Version2 = decode?;
assert_eq!;
Configuring
To tweak the behavior of the storage format you can use the Encoding
type:
use Binary;
use ;
use ;
use Encoding;
const OPTIONS: Options = new.with_integer.build;
const CONFIG: = new.with_options;
let mut out = Vec new;
let expected = Struct ;
CONFIG.encode?;
let actual = CONFIG.decode?;
assert_eq!;