//! Checks compatibility between the "convert" feature and generics use tfhe_versionable::{Unversionize, Versionize, VersionsDispatch}; #[derive(Clone, Versionize)] #[versionize(convert = "SerializableMyStruct")] struct MyStruct { val: u64, generics: T, } #[derive(Versionize)] #[versionize(SerializableMyStructVersions)] struct SerializableMyStruct { high: u32, low: u32, generics: T, } #[derive(VersionsDispatch)] #[allow(unused)] enum SerializableMyStructVersions { V0(SerializableMyStruct), } impl From> for SerializableMyStruct { fn from(value: MyStruct) -> Self { Self { high: (value.val >> 32) as u32, low: (value.val & 0xffffffff) as u32, generics: value.generics, } } } impl From> for MyStruct { fn from(value: SerializableMyStruct) -> Self { Self { val: ((value.high as u64) << 32) | (value.low as u64), generics: value.generics, } } } #[test] fn test() { let stru = MyStruct { val: 37, generics: 90, }; let serialized = bincode::serialize(&stru.versionize()).unwrap(); let stru_decoded: MyStruct = MyStruct::unversionize(bincode::deserialize(&serialized).unwrap()).unwrap(); assert_eq!(stru.val, stru_decoded.val) }