File tree 4 files changed +13
-1
lines changed
4 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " versionize_derive"
3
- version = " 0.1.1 "
3
+ version = " 0.1.2 "
4
4
license = " Apache-2.0"
5
5
authors = [
" Amazon Firecracker team <[email protected] >" ]
6
6
description = " Implements the Versionize derive proc macro."
Original file line number Diff line number Diff line change @@ -71,8 +71,12 @@ impl Descriptor for StructDescriptor {
71
71
72
72
// Generate code to map the app version to struct version and wrap the
73
73
// deserializers with the `version` match.
74
+ let current_version = self . version ( ) ;
74
75
quote ! {
75
76
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
+ }
76
80
match version {
77
81
#versioned_deserializers
78
82
_ => 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 {
40
40
} ) ;
41
41
}
42
42
43
+ let current_version = self . version ( ) ;
43
44
quote ! {
44
45
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
+ }
45
49
match version {
46
50
#versioned_deserializers
47
51
_ => 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 {
50
50
let version = descriptor. version ( ) ;
51
51
let versioned_serializer = descriptor. generate_serializer ( ) ;
52
52
let deserializer = descriptor. generate_deserializer ( ) ;
53
+ let current_version = version;
53
54
let serializer = quote ! {
54
55
// Get the struct version for the input app_version.
55
56
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
+ }
56
60
// We will use this copy to perform semantic serialization.
57
61
let mut copy_of_self = self . clone( ) ;
58
62
match version {
You can’t perform that action at this time.
0 commit comments