1use crate::blob_metadata::{BlobMetadata, BlobMetadataV53};
6use crate::lsm_tree::{
7 PersistentLayerHeader, PersistentLayerHeaderV39, PersistentLayerInfo, PersistentLayerInfoV39,
8};
9use crate::object_store::allocator::{
10 AllocatorInfo, AllocatorInfoV32, AllocatorKey, AllocatorKeyV32, AllocatorValue,
11 AllocatorValueV32,
12};
13use crate::object_store::journal::super_block::{
14 SuperBlockHeader, SuperBlockHeaderV32, SuperBlockRecord, SuperBlockRecordV40,
15 SuperBlockRecordV41, SuperBlockRecordV43, SuperBlockRecordV46, SuperBlockRecordV47,
16 SuperBlockRecordV49, SuperBlockRecordV50,
17};
18use crate::object_store::journal::{
19 JournalRecord, JournalRecordV40, JournalRecordV41, JournalRecordV42, JournalRecordV43,
20 JournalRecordV46, JournalRecordV47, JournalRecordV49, JournalRecordV50,
21};
22use crate::object_store::object_record::{
23 FsverityMetadata, FsverityMetadataV33, FsverityMetadataV50, ObjectKey, ObjectKeyV40,
24 ObjectKeyV43, ObjectValue, ObjectValueV40, ObjectValueV41, ObjectValueV46, ObjectValueV47,
25 ObjectValueV49, ObjectValueV50,
26};
27use crate::object_store::transaction::{
28 Mutation, MutationV40, MutationV41, MutationV43, MutationV46, MutationV47, MutationV49,
29 MutationV50,
30};
31use crate::object_store::{
32 EncryptedMutations, EncryptedMutationsV40, EncryptedMutationsV49, StoreInfo, StoreInfoV40,
33 StoreInfoV49, StoreInfoV52,
34};
35use crate::serialized_types::{Version, Versioned, VersionedLatest, versioned_type};
36use std::collections::BTreeMap;
37
38pub const LATEST_VERSION: Version = Version { major: 53, minor: 0 };
48
49pub const EARLIEST_SUPPORTED_VERSION: Version = Version { major: 40, minor: 0 };
58
59pub const SMALL_SUPERBLOCK_VERSION: Version = Version { major: 44, minor: 0 };
62
63pub const FIRST_EXTENT_IN_SUPERBLOCK_VERSION: Version = Version { major: 45, minor: 0 };
66
67#[allow(dead_code)]
71trait UniqueVersionForType {}
72
73macro_rules! versioned_types {
74 ( $( $name:ident { $latest:literal.. => $latest_type:ty $(, $major:literal.. => $type:ty )* $(,)? } )+ ) => {
75 $(
76 static_assertions::assert_type_eq_all!($name, $latest_type);
77
78 versioned_type! {
79 $latest.. => $latest_type,
80 $( $major.. => $type ),*
81 }
82
83 impl UniqueVersionForType for $latest_type {}
84 $( impl UniqueVersionForType for $type {} )*
85 )+
86
87 pub fn get_type_fingerprints(version: Version) -> BTreeMap<String, String> {
88 let mut map = BTreeMap::new();
89 $(
90 let fingerprint = {
91 let mut fp = None;
92 const FINGERPRINTS: &[(u32, fn() -> String)] = &[
93 ($latest, <$latest_type as fprint::TypeFingerprint>::fingerprint),
94 $( ($major, <$type as fprint::TypeFingerprint>::fingerprint) ),*
95 ];
96 for (major, type_fp) in FINGERPRINTS {
97 if version.major >= *major {
98 fp = Some(type_fp());
99 break;
100 }
101 }
102 fp
103 };
104 if let Some(fp) = fingerprint {
105 map.insert(stringify!($name).to_string(), fp.to_string());
106 }
107 )+
108 map
109 }
110 };
111}
112
113versioned_types! {
114 AllocatorInfo {
115 32.. => AllocatorInfoV32,
116 }
117 AllocatorKey {
118 32.. => AllocatorKeyV32,
119 }
120 AllocatorValue {
121 32.. => AllocatorValueV32,
122 }
123 EncryptedMutations {
124 49.. => EncryptedMutationsV49,
125 40.. => EncryptedMutationsV40,
126 }
127 FsverityMetadata {
128 50.. => FsverityMetadataV50,
129 33.. => FsverityMetadataV33,
130 }
131 JournalRecord {
132 50.. => JournalRecordV50,
133 49.. => JournalRecordV49,
134 47.. => JournalRecordV47,
135 46.. => JournalRecordV46,
136 43.. => JournalRecordV43,
137 42.. => JournalRecordV42,
138 41.. => JournalRecordV41,
139 40.. => JournalRecordV40,
140 }
141 Mutation {
142 50.. => MutationV50,
143 49.. => MutationV49,
144 47.. => MutationV47,
145 46.. => MutationV46,
146 43.. => MutationV43,
147 41.. => MutationV41,
148 40.. => MutationV40,
149 }
150 ObjectKey {
151 43.. => ObjectKeyV43,
152 40.. => ObjectKeyV40,
153 }
154 ObjectValue {
155 50.. => ObjectValueV50,
156 49.. => ObjectValueV49,
157 47.. => ObjectValueV47,
158 46.. => ObjectValueV46,
159 41.. => ObjectValueV41,
160 40.. => ObjectValueV40,
161 }
162 PersistentLayerHeader {
163 39.. => PersistentLayerHeaderV39,
164 }
165 PersistentLayerInfo {
166 39.. => PersistentLayerInfoV39,
167 }
168 StoreInfo {
169 52.. => StoreInfoV52,
170 49.. => StoreInfoV49,
171 40.. => StoreInfoV40,
172 }
173 SuperBlockHeader {
174 32.. => SuperBlockHeaderV32,
175 }
176 SuperBlockRecord {
177 50.. => SuperBlockRecordV50,
178 49.. => SuperBlockRecordV49,
179 47.. => SuperBlockRecordV47,
180 46.. => SuperBlockRecordV46,
181 43.. => SuperBlockRecordV43,
182 41.. => SuperBlockRecordV41,
183 40.. => SuperBlockRecordV40,
184 }
185 BlobMetadata {
186 53.. => BlobMetadataV53,
187 }
188}