toml_migrate
A crate that lets you read versioned config files and easily migrate them to the latest version. Inspired by the magic_migrate library.
Why?
Many applications need their configuration files to evolve over time as features get added and changed. This aims to simplify the process of taking a old config file and transforming it to the latest version.
How does it work?
For every version of your library, define a configuration struct that can be deserialized. This struct should not include the version field:
Then, implement From<PreviousConfig> for all of your config types:
Finally, use the [build_migration_chain!] macro to automatically implement the Migrate trait for all of your structs:
build_migration_chain!;
From there, you can use the [ConfigMigrator] to easily migrate your config file from a string: