This document explains how to save and load versioned data using the data versioning feature.
Starting from v0.6.4, TFHE-rs supports versioned data types. This allows you to store data and load it in the future without compatibility concerns. This feature is done by the tfhe-versionable
crate.
This versioning scheme is compatible with all the data formats supported by serde.
To use the versioning feature, wrap your types in their versioned equivalents before serialization using the versionize
method. You can load serialized data with the unversionize
function, even in newer versions of TFHE-rs where the data types might evolve. The unversionize
function manages any necessary data type upgrades, ensuring compatibility.
Calling .versionize()
on a value will add versioning tags. This is done recursively so all the subtypes that compose it are versioned too. Under the hood, it converts the value into an enum where each version of a type is represented by a new variant. The returned object can be serialized using serde:
The Type::unversionize()
function takes a versioned value, upgrades it to the latest version of its type and removes the version tags. To do that, it matches the version in the versioned enum and eventually apply a conversion function that upgrades it to the most recent version. The resulting value can then be used inside TFHE-rs
When possible, data will be upgraded automatically without any kind of interraction. However, some changes might need information that are only known by the user of the library. These are called data breaking changes. In these occasions, TFHE-rs provides a way to upgrade these types manually.
You will find below a list of breaking changes and how to upgrade them.
We will share code to manage outdated data for this breaking change here shortly.