magic_migrate 2.0.0

Automagically load and migrate deserialized structs to the latest version
Documentation
# use serde::{Deserialize, Serialize};
#
# #[derive(Deserialize, Serialize, Debug)]
# #[serde(deny_unknown_fields)]
# struct PersonV1 {
#     name: String,
#     title: Option<String>,
# }
#
# #[derive(Deserialize, Serialize, Debug)]
# #[serde(deny_unknown_fields)]
# struct PersonV2 {
#     name: String,
#     job_title: String,
# }
#
# #[derive(Debug, Eq, PartialEq, thiserror::Error)]
# #[error("Title cannot be empty")]
# struct TitleCannotBeEmpty;
#
# impl From<TitleCannotBeEmpty> for PersonMigrationError {
#     fn from(value: TitleCannotBeEmpty) -> Self {
#         PersonMigrationError::TitleCannotBeEmpty
#     }
# }
#
# #[derive(thiserror::Error, Debug, Eq, PartialEq)]
# enum PersonMigrationError {
#     #[error("Title cannot be empty!!!")]
#     TitleCannotBeEmpty,
# }
#
# impl TryFrom<PersonV1> for PersonV2 {
#     type Error = TitleCannotBeEmpty;
#
#     fn try_from(value: PersonV1) -> Result<Self, TitleCannotBeEmpty> {
#         if let Some(title) = value.title {
#             if title.is_empty() {
#                 Err(TitleCannotBeEmpty)
#             } else {
#                 Ok(PersonV2 {
#                     name: value.name,
#                     job_title: title,
#                 })
#             }
#         } else {
#             Err(TitleCannotBeEmpty)
#         }
#     }
# }