frozone
frozone is a crate that allows you to 'freeze' structs and enums
recursively to ensure they never get changed, helping enforcing
backwards-compatibility or API stability (arewesemveryet.org ?)
Use case
Let's say there is a very important data structure for your application:
that gets serialized in ~/.config/frozone/state.json
on each user's machine. You've released v1 and everyone is happy.
However, for v2, you realize that you would prefer super_suit to be
included in equipment instead. Good, but now, whenever your v2
program runs and tries to load a 'v1' config, your deserializer will
rightfully tell you: Honey, where's my super_suit ?
You probably know that the answer to this backward-compatibility issue is to add a version field, save the old structure tree somewhere, and create new ones
Of course, you'll never forget to check that no similar changes during
the v1->v2 development have affected Power: a deeply-nested struct,
with enough optional fields to make coverage testing a full-on PhD thesis,
spanning multiple modules/crates/developer's responsibilities.
OF COURSE, RIGHT ?
frozone enforces your 'object tree' semantically never changes, ensuring
serialization and API stability.
Usage
use Freezable;
// ...
What's frozen and what's not
// note: the order of the fields is "not frozen"
// note: the order of the variants is "not frozen"
Roadmap
- structs support
- enums support
- compile-time check (probably requires const trait = nightly Rust)