File tree Expand file tree Collapse file tree 4 files changed +13
-1
lines changed Expand file tree Collapse file tree 4 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " versionize_derive"
3- version = " 0.1.1 "
3+ version = " 0.1.2 "
44license = " Apache-2.0"
55authors = [
" Amazon Firecracker team <[email protected] >" ]
66description = " Implements the Versionize derive proc macro."
Original file line number Diff line number Diff line change @@ -71,8 +71,12 @@ impl Descriptor for StructDescriptor {
7171
7272 // Generate code to map the app version to struct version and wrap the
7373 // deserializers with the `version` match.
74+ let current_version = self . version ( ) ;
7475 quote ! {
7576 let version = version_map. get_type_version( app_version, <Self as Versionize >:: type_id( ) ) ;
77+ if app_version == version_map. latest_version( ) && version != #current_version {
78+ return Err ( VersionizeError :: VersionMapNotUpdated ) ;
79+ }
7680 match version {
7781 #versioned_deserializers
7882 _ => panic!( "Unknown {:?} version {}." , <Self as Versionize >:: type_id( ) , version)
Original file line number Diff line number Diff line change @@ -40,8 +40,12 @@ impl Descriptor for UnionDescriptor {
4040 } ) ;
4141 }
4242
43+ let current_version = self . version ( ) ;
4344 quote ! {
4445 let version = version_map. get_type_version( app_version, Self :: type_id( ) ) ;
46+ if app_version == version_map. latest_version( ) && version != #current_version {
47+ return Err ( VersionizeError :: VersionMapNotUpdated ) ;
48+ }
4549 match version {
4650 #versioned_deserializers
4751 _ => panic!( "Unknown {:?} version {}." , Self :: type_id( ) , version)
Original file line number Diff line number Diff line change @@ -50,9 +50,13 @@ pub fn impl_versionize(input: TokenStream) -> proc_macro::TokenStream {
5050 let version = descriptor. version ( ) ;
5151 let versioned_serializer = descriptor. generate_serializer ( ) ;
5252 let deserializer = descriptor. generate_deserializer ( ) ;
53+ let current_version = version;
5354 let serializer = quote ! {
5455 // Get the struct version for the input app_version.
5556 let version = version_map. get_type_version( app_version, <Self as Versionize >:: type_id( ) ) ;
57+ if app_version == version_map. latest_version( ) && version != #current_version {
58+ return Err ( VersionizeError :: VersionMapNotUpdated ) ;
59+ }
5660 // We will use this copy to perform semantic serialization.
5761 let mut copy_of_self = self . clone( ) ;
5862 match version {
You can’t perform that action at this time.
0 commit comments